Hey! I have a little problem with the following code onClipEvent (load) { _y = 0; speed = 3; } onClipEvent (enterFrame) { endY = _root._ymouse; _y += (endY-_y)/speed; } what i want is that the object doesn't start moving directly with the mouse pointer but when the pointer is for example 1 cm over or under the object. cause i want to be able to move the mouse pointer freely inside the object and that it starts to move when the pointer gets outside the object's border. thx for your time!
use a rollOut() handler to initiate your loop that updates your object's _y property. also, you should develope a habit of terminating loops that are no longer needed (ie, when _y and _root._ymouse have nearly the same value).
I've just started working with flash.. so sorry for sounding a bit stupid but could you write how a code like that could look like using the rollOut() dont know if it helps but the objects hight is around 2 cm, so i would like to be able to move the mouse 2 cm before the whole thingy starts to move. would be greatful for answer!
if your object has instance name obj1, you can use the code below. obj1 will start moving as soon as the mouse rolls out. if you want a border around the obj1 outside of which would trigger movement, use a shape with _alpha zero on obj1's timeline to create the border: obj1._y=0; obj1.speed=3; obj1.onRollOut=function(){ mc=this; clearInterval(this.moveI); this.moveI=setInterval(moveF,70,mc); } function moveF(mc){ mc._y+=(_root._ymouse-mc._y)/mc.speed; if(Math.abs(mc._y-_root._ymouse)<1){ clearInterval(mc.moveI); } }
Don't see what you're looking for? Try a search.
|