onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
// /////////////
if (_root.hitbar._x>_root._xmouse) {
_root.hitbar._x = _root.hitbar._x-((_root.hitbar._x-_root._xmouse)/speed);
}
}
if (_root.hitTest(_root._xmouse, _root._ymouse)) {
if (_root.hitbar._x<_root._xmouse) {
_root.hitbar._x = _root.hitbar._x+((_root._xmouse-this.hitbar._x)/speed);
// /////////////////////////
}
}
}
however I cant get the script to work
Im placing this script on a movie clip, there is a second MC whose instance name is “hitbar” and when the mouse hits this MC it should trigger the first MC to travel along the X axis…
very nice, is there a way( withen the same script) to restrain the pink MC to only move be able to move to a certain x position? I dont want the pink MC to be able to move further than the hitarea box.
You can use conditional statements again for that. You can compare the _x position and the width of the hit area MC as the borders. I’ll give your file shot tomorrow. I’ll have to take a rest!