ActionScript 2移动对象 [英] ActionScript 2 Moving an object

查看:101
本文介绍了ActionScript 2移动对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对ActionScript知之甚少。

I have very little knowledge of ActionScript.

我有一个影片剪辑。当我按下按钮(按钮或影片剪辑)时,我希望它沿x轴移动。我不知道要使用什么代码,因为它必须是动作脚本2。

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

谢谢您帮助

更新

该按钮称为 btn 并且移动的对象是 mctransparent 我已经完成了以下操作:

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;
}

这是在btn的动作面板上

This is on the actions panel of the btn

但是,当您单击必须移动的对象时,它就会移动。我无法获得它,因此仅当您单击并按住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.

推荐答案

您可能会遇到类似以下内容( btnToClick_btn 是按钮/影片剪辑的名称, objectToMove_mc 是要移动的MovieClip):

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 被解雇单击后释放鼠标按钮的时间。如果要在按下鼠标按钮时移动对象,可以使用 onPress

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.

您应该放置此代码在时间轴的第一帧中,您应该在舞台上btnToClick_btn和objectToMove_mc。

You should put this code in the first frame of the Timeline AND you should have on the stage btnToClick_btn and objectToMove_mc.

这篇关于ActionScript 2移动对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆