Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

isAtLabel.as

Name: isAtLabel() - Checks if a movieclip is at a specific label
Author: senocular: www.senocular.com
Date: 1899-12-31T00:24:25.000
Documentation:
MovieClip ISATLABEL: Checks if a movieclip is at a
specific label.  If so true is returned, otherwise false

WARNING!:
- All frame scripts in the frame lable checked (if different) and the current frame of the
movieclip checked will be RE-RUN after the playhead returns to that frame.  Because of this,
do not call this function from the frame or you wil be stuck in an infinite loop (and be
cautious of all frame scripts at labels as they too will be run).

Arguments:
- label: the label to check for
- state: (optional, string)the state of play after the label is checked.  Should the
movieclipn play or stop.  "play" is passed if it should play, "stop" is passed if it should stop.
"play" is default.

Returns:
- true if the movieclip is currently at the specified label, false if not

Example:
if (my_mc.isAtLabel("myLabel")){
	// do something
}

1
2
3
4
5
6
7
8
9
MovieClip.prototype.isAtLabel = function(label, state){
	state = state.toLowerCase();
	if (state != "stop" || state != "play") state = "play";
	var iniFrame = this._currentframe;
	this.gotoAndStop(label);
	var returnVal = (this._currentframe == iniFrame);
	this["gotoAnd"+state](iniFrame);
	return returnVal;
}