2
votes

For the life of me I can't figure out how to trace out the current label in my movie's main timeline. This is in AS3.

I have a button on stage that spans the timeline of the movie. It detects keypresses. I want to trace the current frame label that the play head is on.

on(keypress "<left>") { 
 trace(this);
 trace(this.currentFrameLabel);
 trace(this.currentLabel);
 trace(currentFrameLabel);
 trace(currentLabel);
} 

I get "_level0" for this...and undefined for the rest. What am I doing wrong here?

1
You seem to be mixing AS2 and AS3 up. - typeoneerror
I guess I should say that I've inherited someone's movie and it is an AS3 movie. You're right, the code is not AS3. :) - milesmeow
The answer solves the OP's problem but is completely unrelated to the title question. Hence, I've proposed to change the title. - o0'.

1 Answers

3
votes

Are you publishing an AS1/2 or an AS3 movie? on(keypress "left") is AS1 (not even 2), and currentFrameLabel and currentLabel are AS3 properties of the MovieClip class. You'll need to use event listeners in AS3:

addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownHandler);

And if you are publishing for AS2, currentFrameLabel and currentLabel will be undefined but AS1/2 has the MovieClip._currentframe property which is an integer.

AS2 and AS3 are compiled into different bytecode (AS1/2 gets compiled to AVM1 and AS3 to AVM2), so you cannot have them in the same compiled swf file.