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

 

senocular.com ActionScript Library

setEnterFrame.as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
MovieClip.prototype.setEnterFrame = function(/* method, arguments */){
	var f = arguments.shift();
	if (typeof f == "string") f = this[f];
	var a = arguments, m = arguments.callee;
	if (!this._eflisteners){
		this._eflisteners = new Array();
		this.clearEnterFrame = m.clearEnterFrame;}
	this.onEnterFrame = m.enterFrame;
	var e = function(){ f.apply(arguments.callee.owner, a); }
	e.owner = this; e.id = m.id++;
	this._eflisteners.unshift(e);
	return f.id;
}
MovieClip.prototype.setEnterFrame.id = 0;
MovieClip.prototype.setEnterFrame.enterFrame = function(){
	var f = this._eflisteners;
	var i = f.length
	while (i--) f[i]();
}
MovieClip.prototype.setEnterFrame.clearEnterFrame = function(id){
	var e = this._eflisteners;
	var i = e.length;
	while(i--){
		if (e[i].id == id){
			e.splice(i,1);
			return true;}}
	return false;
}