Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 11-30-2009, 01:26 PM   #1
beattie282
Registered User
problem with if statment

i have a slideshow what basicaly goes thru 5 pictures
but the if statment is not working correctly an i cannot find out why could you please help?

my code

Code:
stop();


next_btn.onRelease = function()  {
    if (_root._currentframe == 997){
        gotoAndStop(992);
    }
    else {
        nextFrame();
    }
}

back_btn.onRelease = function() {
    if (_root._currentframe == 992){
        gotoAndStop(997);
    }
    else {
        prevFrame();
    }
}
the back_btn works correctly and goes to the last fra,e where the last picture in the slidshow is but the next button keeps on taking me to frame 1
thankyou in advanced

P.S i can upload the file if you wish to see it

Beattie282
beattie282 is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-30-2009, 01:41 PM   #2
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,161
At a quick glance, there's no reason why that code alone wouldn't cycle through frames 992-997 and then return to frame 992. So it's possible that there's some additional code on frames 1-991 that is interfering with the next_btn, or you're using scenes which has messed up the frame numbering.

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Old 11-30-2009, 02:18 PM   #3
beattie282
Registered User
Quote:
Originally Posted by glosrfc View Post
At a quick glance, there's no reason why that code alone wouldn't cycle through frames 992-997 and then return to frame 992. So it's possible that there's some additional code on frames 1-991 that is interfering with the next_btn, or you're using scenes which has messed up the frame numbering.

yea i am using scenes but i got the frame numbers from this function to display into the dynamic text feild

Code:
onEnterFrame=function(){ 
    _root.displayNumber=_root._currentframe;
}
this is where i found my frame numbers from ive also tryed all the close numbers like 99"6/8/9" but nothing happens

p.s:

i would not of used scenes if i knew how much hassle they are i only found out today that i had to lable frames to jump around scenes because of the way flash compliles the whole file as one so therfore only one timeline.
thankyou for you help by the way mate
beattie282 is offline   Reply With Quote
Old 11-30-2009, 03:29 PM   #4
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,161
One of the drawbacks to using scenes is that it messes up the numbering of your frames. Unfortunately, there's no corresponding _currentlabel in AS2

What you can try doing though is to give frames 992 and 997 a label, e.g. "start" and "end"
Then, on each of those frames place a variable:
on frame 992 put thisLabel = "start";
on frame 997 put thisLabel = "end";

Then change your code to this:
ActionScript Code:
next_btn.onRelease = function()  {
    if (thisLabel == "end"){
        gotoAndStop("start");
    }
    else {
        nextFrame();
    }
}

back_btn.onRelease = function() {
    if (thisLabel == "start"){
        gotoAndStop("end");
    }
    else {
        prevFrame();
    }
}

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Old 12-01-2009, 10:30 AM   #5
beattie282
Registered User
ermmm how do i add variables to frames? ive got literaly no idea i only started flash like 2 weeks ago
beattie282 is offline   Reply With Quote
Old 12-01-2009, 10:53 AM   #6
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,161
You should already have a keyframe on frame 992. In the Actions panel, put:
var thisLabel = "start";
You should see the a symbol appear in this frame on the Timeline which shows that you have actionscript located there.
Do the same thing for frame 997

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Old 12-01-2009, 11:11 AM   #7
beattie282
Registered User
YAY Thank you mate!! much appreciated, it wasent working at first then i had a tought about the buttons i realized i had copied other buttons so thats what was making it mess up

and thanks agen mate ur a life saver
beattie282 is offline   Reply With Quote
Old 12-01-2009, 11:16 AM   #8
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,161
No problem. One thing's for sure...you probably won't be using scenes again

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:29 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com