# onEnterFrame efficiency

**URL:** <https://forum.kirupa.com/t/onenterframe-efficiency/27333>\
**Category:** flash\
**Created:** [August 1, 2003, 6:33am UTC](https://forum.kirupa.com/t/onenterframe-efficiency/27333 "2003-08-01T06:33:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nocturn](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Nocturn](https://forum.kirupa.com/u/Nocturn)\
**Post date:** [August 1, 2003, 6:33am UTC](https://forum.kirupa.com/t/onenterframe-efficiency/27333/1 "2003-08-01T06:33:26Z")

</div>

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

```auto

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2003, 6:51am UTC](https://forum.kirupa.com/t/onenterframe-efficiency/27333/2 "2003-08-01T06:51:34Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2003, 6:55am UTC](https://forum.kirupa.com/t/onenterframe-efficiency/27333/3 "2003-08-01T06:55:28Z")

</div>

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](http://www.kirupa.com/developer/actionscript/tricks/dynamicevent.asp)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2003, 7:03am UTC](https://forum.kirupa.com/t/onenterframe-efficiency/27333/4 "2003-08-01T07:03:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2003, 7:10am UTC](https://forum.kirupa.com/t/onenterframe-efficiency/27333/5 "2003-08-01T07:10:31Z")

</div>

Yeah, I think so.

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