all groups > flash actionscript > january 2007 >
You're in the

flash actionscript

group:

Code not working!


Code not working! Mr. Rish
1/1/2007 9:32:56 PM
flash actionscript:
I am using the partial code below to keep the movieclip from following my mouse
after i get to close to the sides of the flash window. It isn't working
though-- any thoughts?

if (_root._xmouse>(Stage.width/4) &&
_root._xmouse<(Stage.width-Stage.width/4)) {
rvk.onEnterFrame = function() {
var xMouse = _root._xmouse;
if (Math.abs(xMouse-this._x)<1) {
this._x = xMouse;
} else {
this._x -= (this._x-xMouse)/100;
}
};
}
Re: Code not working! kglad
1/1/2007 10:29:47 PM
yes, it's not going to work. either that code you posted is looping and you'll
repeatedly define that onEnterFrame loop (which is unnecessary) and that
onEnterFrame loop will never stop (even when the mouse is near your stage
edge). or that code is not looping and will execute once when your mouse will
likely not be detected and that onEnterFrame loop will never be defined.

to remedy use:



rvk.onEnterFrame = function() {
if (_root._xmouse>(Stage.width/4) &&
_root._xmouse<(Stage.width-Stage.width/4)) {
var xMouse = _root._xmouse;
if (Math.abs(xMouse-this._x)<1) {
this._x = xMouse;
} else {
this._x -= (this._x-xMouse)/100;
}
}
};
AddThis Social Bookmark Button