This came to me as a surprise as there are
two properties of a movieclip for the label of a frame. “currentLabel” and
“currentFrameLabel” are those two properties which will give you the label
string of a particular frame. There is a very subtle difference in these two.
currentFrameLabel : This gives the string value of the label of the
current frame. And this is different for each(lets stress,its different for
each) frame unless not defined,in that case it would be null.
currentLabel : This too gives
the string value of the label of the current frame. But it is same for the in
between frames (the frames between 2 different labels). It returns the label of
the current frame if its defined,else it returns the label of the previous
frame, else it will return the label of the last to last frame. If there are no
labels defined from the beginning, then only it will return null.
Sample Code :-
package
{
import
flash.display.MovieClip;
import
flash.events.Event;
public
class UnderstandingLabel extends MovieClip
{
public
function UnderstandingLabel():void
{
trace(this,'
: Constructor : ');
this.init();
}
private
function init():void
{
this.addEventListener(Event.ENTER_FRAME,checkOnEachFrame);
}
private
function checkOnEachFrame(e:Event):void
{
trace(this,':checkOnEachFrame
:: this.currentFrame=',this.currentFrame);
trace(this,':checkOnEachFrame
:: this.currentLabel=',this.currentLabel,'::
this.currentFrameLabel=',this.currentFrameLabel);
if(this.currentFrameLabel!=null)
{
trace('-----------------------------------------At
frame number',this.currentFrame,' this.currentFrameLabel !=null');
}
if(this.currentFrame>=this.totalFrames)
{
this.removeEventListener(Event.ENTER_FRAME,checkOnEachFrame);
}
}
}
}
No comments:
Post a Comment