While working in Adobe Flash, there are times when you want to know the current frame number of the play head. To display current frame of the movie, draw a TectField on stage, and give it a instance name “frameTxt” using Properties Panel.
Put following code in the Actions Panel on frame 1 in ActionScript 3 document:
function showCurrentFrame(evt:Event):void { var frame:Number; frame = currentFrame; frameTxt.text = (String(frame)); trace(frame); } frameTxt.addEventListener(Event.ENTER_FRAME, showCurrentFrame);
The code is self explanatory. As the play head moves on main timeline, EnterFrame eventListener will update currentFrame number in the TextField on stage and will also trace it in Debugger.
Hope that helps.
Cheers!
hi Ali,
i load an swf file to a movie clip…
and i have Pause and Play button for playing and pausing that external swf file..
i tried to use this script to informs myself which frame is playing right now..
but how can i use that information to make that file stop?
see this post for external swf player.
trace(currentFrame); show only “1”. its not showing the playing timeline frames. I am looking for the timeline base slider control to slider should move along with timeline. any guesses
It shows the Main timeline of the swf movie, not the playing timeline. Playing timeline can be in any nested MovieClip.
Hi,
How would look the switch, if I would like to do the action on a specific frame.
For example:
switch(currentFrame) {
case “1” :
gotoAndPlay(5);
break;
case “10” :
stop();
break;
}
Thanks in advance!
Hope that helps.