hello!
i’ve got a little actionscript that makes a shape follow my mouse about the screen. it works fine when i place it in a layer. however, when the code is in a mc and i place the mc in my layer, then i get no joy
i expect i need a line like tellTarget when using buttons within a mc to target places outside the mc?
any helps is appreciated
You probebly need to change a small piece of the code.
What is the code you currently are using for the “follow”?
i have a graphic named box and an empty movie clip with 2 frames
frame1:
if (_root._xmouse>_level0.box._x) {
        _level0.box._x = (_level0.box._x+10);
} else {
        _level0.box._x = (_level0.box._x-10);
}
frame2:
if (_root._xmouse>_level0.box._x) {
        _level0.box._x = (_level0.box._x+10);
} else {
        _level0.box._x = (_level0.box._x-10);
}
gotoAndPlay (1);
PS i found the example on the net, so i’ve no idea if this is the best way of doing things
cheers
well you could try it like this…
frame1:
if (_parent._xmouse>_parent.box._x) {
_parent.box._x = (_parent.box._x+10);
} else {
_parent.box._x = (_parent.box._x-10);
}
frame2:
if (_parent._xmouse>_parent.box._x) {
_parent.box._x = (_parent.box._x+10);
} else {
_parent.box._x = (_parent.box._x-10);
}
gotoAndPlay (1);
but personaly I would do it like this.
take the same box and place it on the stage in a new blank layer. Select it, and check it out in the “instance” panel. If it is there and lists it as a movie clip, you can do this trick… If not, switch it to a movie clip in the instance panel. It will work just as well.
Now you just select it, open the “action” panel, and type in the following.
onclipEvent(enterFrame){
diff=_x-_root.mouse;
_x+=diff/4;
}
you can change the rate of movement by dividing the diff by higher and higher numbers.
superb!
you make it look easy!
the reason i wanted this feature inside a movieclip and not directly on the layer is bacause the mc is the whole gui (which i place on the layer), and in that gui ther are 4 buttons in a corner - and i only want the shape-that-follows-the-mouse to happen in that corner of the screen. but i can set it up on the layer and just use a mask around the corner of the screen (the gui mc, when placed on the layer) where the buttons appear
cheers!