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

Some help with understanding the way ac3 works.

New Here ,
May 23, 2015 May 23, 2015

Hello guys, im new to ac3, and im messing around with it for about a week now.
ill paste my code and then i will explain whats not working, please don't only fix my code, i would like to understand why it not working like i want it to.
My Code:

stop();

var TextCount:int = 1;

addEventListener(Event.ENTER_FRAME , FramePos );

function FramePos (e:Event):void{

  var MyFrame:int = this.currentFrame;

   

  if (MyFrame == 1){

  gotoAndStop(1);

  }

  if(MyFrame == 14){

  gotoAndStop(1);

  }

  if(MyFrame==3){

  TextCount=4;

  }

  my_text.text=("Frame :" + MyFrame + "TexCount is: " + TextCount);

}

o whuy

so i have my var TextCount, is first set to 1, then i say : if MyFrame==3 TextCount=4 , now when i run this, every time it goes to frame 3 textcount becomes 4 , but then when movie clip go back to frame 1, it goes back to be 1.

and i don't understand why, i was thinking that only what goes in enter frame function lunches when it enters a frame, and that other code just lunches once, i see now i was wrong,

how can i write this correctly?


Thanks A head to all people who take there time to read this and try to help.

TOPICS
ActionScript
258
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
Community Expert ,
May 23, 2015 May 23, 2015
LATEST

probably because you have that code on frame 1.  ie, you're 2nd line of code is resetting TextCount to 1.

the enterframe funciton executes whether frames change or not as you should see when your movie starts and that first line (stop() ) of code executes.

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