View Full Version : delete this.onEnterFrame
markhegz
January 30th, 2004, 02:07 PM
i am using the following AS to scale a movieclip with ease
onClipEvent(load){
targe_width = _width;
}
onClipEvent(enterFrame){
targe_width = 360;
_width = _width += (targe_width - _width)/3.6;
}
should i be using a delete this.OnEnterFrame when the clip reaches the desired width? the problem is that ive noticed a lag in my tweens and i wonder if this is whats causing it.
any ideas?
claudio
January 30th, 2004, 02:31 PM
You will have to use dynamic event handler if you want to delete the event later.
kill.robot.kill
January 30th, 2004, 02:31 PM
put trace(_width); after your second line, you will see if change in multiples of like .00000000000000001, and that is no doubt bogging down your movie.
kill.robot.kill
January 30th, 2004, 02:54 PM
I made a real quick 'hack' for this, I am sure this is a better way, but if you are still using onClipEvents and not dynamic handlers like claudio suggested, this will work.
code on your MC:
onClipEvent (load) {
targe_width = 360;
}
onClipEvent (enterFrame) {
if (_parent.goCheckWidth) {
_parent.checkWidth();
}
}
code on a key frame:var goCheckWidth = true;
function checkWidth() {
trace(box._width);
if (box._width>359) {
box._width = 360;
goCheckWidth = false;
trace("done");
} else {
box._width = box._width += (box.targe_width-box._width)/3.6;
trace(box._width);
}
}
I used "box" as the instance name for your MC, so just change that.
If someone has better fix, not using dynamic event handlers, I'd love to see it, I just did this real quick.
markhegz
January 30th, 2004, 03:06 PM
thanks for the help...
when i used trace width the output just goes on forever...
so i tried this: (thanks voetsjoba)
MovieClip.prototype.resize = function (w,h) {
this.onEnterFrame = function () {
this._width = w-(w-this._width)/1.2
this._height = h-(h-this._height)/1.2
if(this._width < w+1 && this._width > w-1 && this._height < h+1 && this._height > h-1) {
trace(_width);
delete this.onEnterFrame
}
}
}
seems to do the trick....
kill.robot.kill
January 30th, 2004, 03:19 PM
cool, I knew you would get better results with dynamic event handlers using updated syntax
markhegz
January 30th, 2004, 03:51 PM
its starting to work better but i used onEnterFrames for everything. now i have to go back and rebuild the whole thing....
markhegz
January 30th, 2004, 05:01 PM
site is still running slow.....do you think its my hosting?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.