I have very little knowledge of ActionScript.
I have a movie clip. I want it to move along the x-axis when i press down on a button(button or movie clip) I do not know what code to use as it needs to be Action Script 2.
Is there a Tutorial or something that can accomplish this?
I have found a tutorial that moves the object around when you press a button. I am trying to get the same effect when you click down on a button:
http://www.kirupa.com/developer/actionscript/xymove.htm
Thank you for any help
UPDATE
The button is called btn
and the object that moves is mctransparent
I have managed the folowing:
onClipEvent (mouseDown) {
_root.mctransparent.onEnterFrame = function() {
if (_root._xmouse<_root.mctransparent._x) {
_root.mctransparent._x -= 10;
} else {
_root.mctransparent._x += 10;
}
};
}
onClipEvent (mouseUp) {
delete _root.mctransparent.onEnterFrame;
}
This is on the actions panel of the btn
But when you click on the object that must move it moves. I cannot get it so the object only moves when you click and hold on the btn.
You could have something like this (
btnToClick_btn
is the name of a button/movieclip andobjectToMove_mc
is a MovieClip to move):onRelease
is fired when, after clicking, you release the mouse button. You can useonPress
if you want the object move when you press the mouse button.You should put this code in the first frame of the Timeline AND you should have on the stage btnToClick_btn and objectToMove_mc.
Instead of listening for the
keyPress
event, listen for thepress
orrelease
event.so you'd have
or
Alternatively, you could remove the
btn_clickMe.
and put the code in thebtn_clickMe
's actions panel.