ActionScript 2 Moving an object

社会主义新天地 提交于 2019-12-02 12:40:38

Instead of listening for the keyPress event, listen for the press or release event.

so you'd have

btn_clickMe.onPress = function() {
    //whatever moving logic you are using
}

or

btn_clickMe.onRelease = function() {
    //whatever moving logic you are using
}

Alternatively, you could remove the btn_clickMe. and put the code in the btn_clickMe's actions panel.

You could have something like this (btnToClick_btn is the name of a button/movieclip and objectToMove_mc is a MovieClip to move):

// this moves objectToMove_mc 10 pixels right any time you click the button
btnToClick_btn.onRelease=function(){
   objectToMove_mc._x+=10;
}

onRelease is fired when, after clicking, you release the mouse button. You can use onPress 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!