Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

if current frame == 1 dosomething ... else (currentFrame ==2) do something else. Not working.

Guest
Nov 06, 2009 Nov 06, 2009

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");
     }
}

TOPICS
ActionScript
11.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Nov 06, 2009 Nov 06, 2009

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

Translate
Mentor ,
Nov 06, 2009 Nov 06, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 06, 2009 Nov 06, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Nov 06, 2009 Nov 06, 2009

LMAO!  omg, kalisto - i can't believe i didn't see that! PHAHAHAHAHAH!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 06, 2009 Nov 06, 2009

And "LMAO" is?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2009 Nov 06, 2009

I believe he means "Laughing my a** off"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 06, 2009 Nov 06, 2009

10x

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Nov 06, 2009 Nov 06, 2009
LATEST

yup that's right - laughing at my own stupidity for not noticing that error -  LOL! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2009 Nov 06, 2009

oh perfect that works thanks!

clbeech thanks for pointing out the Event. I made a mistake there and didnt notice

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines