Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now