onEnterFrame efficiency

Hi,

I have taken the script from one of the tutorials on kirupa, about the mc easing to mouse position, and adapted it to scale a navigation “window”. The script looks like this


onClipEvent (load) {
	_xscale = 0;
	_yscale = 1;
	speed = 3;
}
onClipEvent (enterFrame) {
	if(_xscale <99){
	endX = 100;
	_xscale += (endX-_xscale)/speed;
	} else if(_yscale <99){
	endY = 100;
	_yscale += (endY-_yscale)/speed;
		}
}

My question is if this is an efficient way of doing it. I have this script attached to 3 mc’s so Flash will continually check these 3 clips now? Does this take up to many resources? Is there a better way of doing it, without using onClipEvent? Sort of like, once the windows are scaled to 100%, I want Flash to forget checking them.

The kind of effect I’m going after you can see on this site:
http://www.leos-baden-baden.de/catering/

The white stripes that load the elements. What’s a good way of making that effect?

You can use dynamic event handlers, which you can delete whenever you wish.

… That would be something like this:
[AS]clip._xscale = 0;
clip._yscale = 1;
speed = 3;
clip.onEnterFrame = function() {
if (this._xscale<99) {
endX = 100;
this._xscale += (endX-this._xscale)/speed;
} else if (this._yscale<99) {
endY = 100;
this._yscale += (endY-this._yscale)/speed;
} else {
delete this.onEnterFrame;
}
};[/AS]
Where clip is the instance name of your MovieClip.

http://www.kirupa.com/developer/actionscript/tricks/dynamicevent.asp

Great, thanks! Just what I was wondering about:)
Do you think the script above is a good way of achieving that expanding windows effect?

Yeah, I think so.

Besides, as long as it works… everything’s valid. :wink: