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

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

Guest
Nov 06, 2009 Nov 06, 2009

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

TOPICS
ActionScript

Views

10.5K

Translate

Translate

Report

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

Votes

Translate

Translate
Guru ,
Nov 06, 2009 Nov 06, 2009

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

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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
Guru ,
Nov 06, 2009 Nov 06, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

And "LMAO" is?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

10x

Votes

Translate

Translate

Report

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
Guru ,
Nov 06, 2009 Nov 06, 2009

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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