Copy link to clipboard
Copied
Im having a little bit of trouble trying to make a button give me different results based on what frame the main timeline is on.
I am trying to get a button to go to a different link based on what frame the main timeline is on. If I am on frame 5 It will trace back "4" .. that is fine but other frames trace back the frame number and also 4.
frame 2 click of button traces back 1 and 4
frame 3 click of button traces back 2 and 4
frame 4 click of button traces back 3 and 4
frame 5 click of button traces back 4
thanks for your advice.
function buttonClicked(e:Event):void
{
if(currentFrame == 2)
{
trace("Clicked 1");
}
else if(currentFrame == 3)
{
trace("Clicked 2");
}
else if(currentFrame == 4)
{
trace("Clicked 3");
}
else (currentFrame == 5)
{
trace("Clicked 4");
}
}
You have a misstake else (currentFrame == 5) do nothing but it is used for else. After that trace("Clicked 4"); is simple command
or in other words:
else (currentFrame == 5)
{
trace("Clicked 4");
}
is equal to
else (currentFrame == 5)
trace("Clicked 4"); // this will alway be executeds
Copy link to clipboard
Copied
hmmm - well it seems that the final 'else' is causing the statement to fail - not certain why at this time - odd in a way - however to remedy, use an 'if else' as the final condition. also you'll want to change the event object type to MouseEvent - rather than just Event
Copy link to clipboard
Copied
You have a misstake else (currentFrame == 5) do nothing but it is used for else. After that trace("Clicked 4"); is simple command
or in other words:
else (currentFrame == 5)
{
trace("Clicked 4");
}
is equal to
else (currentFrame == 5)
trace("Clicked 4"); // this will alway be executeds
Copy link to clipboard
Copied
LMAO! omg, kalisto - i can't believe i didn't see that! PHAHAHAHAHAH!
Copy link to clipboard
Copied
And "LMAO" is?
Copy link to clipboard
Copied
I believe he means "Laughing my a** off"
Copy link to clipboard
Copied
10x
Copy link to clipboard
Copied
yup that's right - laughing at my own stupidity for not noticing that error - LOL!
Copy link to clipboard
Copied
oh perfect that works thanks!
clbeech thanks for pointing out the Event. I made a mistake there and didnt notice