views:

392

answers:

1

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?

+2  A: 

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.

Typeoneerror
You are totally right. They were publishing as AS2! This is a quick and dirty job so I'm just using _currentframe. No style points for this project. :) Thanks!
milesmeow