PDA

View Full Version : fundamental actionscript onClipEvent question


carlhusic
01-02-2003, 06:08 PM
OK - I'm trying to just get an object (movie clip symbol consisting
of a blue circle) to follow the cursor around. I attached the
following to the object instance on the stage:

onClipEvent (mouseMove) {
this._x = _xmouse;
this._y = _ymouse;
}

When I move the cursor the thing just kind of jerks around
and doesn't follow the cursor very well.

Obviously there needs to be a lot more than the little bit of code
that I have in here - can someone clue me in, or just point me to
an example that does this fundamental thing the way it should
be done?


Carl

Mortimer Jazz
01-02-2003, 06:32 PM
not really much code needed to be honest :)

Using a sililar method to yours you can do this ("enterFrame" instead of using on "mouseMove"):
onClipEvent(enterFrame){
this._x = _parent._xmouse;
this._y = _parent._ymouse;

}
Because you're putting the code on a clip it seems you need to target _parent._xmouse (or _root.xmouse, both achieve the same thing here).
This surprised me a little to be honest as I though _xmouse and _ymouse took a global value, but without the path the whole thing went completely heywire in FlashMX and almost gave me a seizure.

There are other methods for draging stuff around including "drag".
Hope this helps