【问题标题】:make movie clip with function mouse down in action script 3在动作脚本3中使用功能鼠标制作影片剪辑
【发布时间】:2015-12-23 07:59:18
【问题描述】:

我会让我的锤子(电影剪辑)跟随光标,每次我点击鼠标/鼠标时,锤子都会下降暴露光标并返回到原始位置。但我只能让锤子(电影剪辑)跟随光标。我该怎么办?

hammer.startDrag(true);

【问题讨论】:

    标签: actionscript-3


    【解决方案1】:

    首先,您应该创建一个您希望锤子在单击时执行的动画。然后在用户按下鼠标时执行该动画。

    假设锤子有一个动画,然后从第 2 帧开始;

    private function MainFunction():void
    {
        hammerMC.addEventListener(MouseEvent.MOUSE_DOWN, CursorDown);
        hammerMC.addEventListener(MouseEvent.MOUSE_UP, CursorUp);
        //and other required events...
    }
    
    private function CursorDown(ref:MouseEvent):void
    {
        hammerMC.gotoAndPlay(2);//hammerMC.nextFrame();
        //...
    }
    
    private function CursorUp(ref:MouseEvent):void
    {
        //we do this because we want cursor comes back to default status after we release the mouse button
        //otherwise it sticks to mouse down animation
        hammerMC.gotoAndStop(1);
        //...
    }
    

    我想这足以完成这项工作。

    【讨论】:

    • 感谢您的回答@coner,我试了一下,但出错了。那么,我该怎么办?
    • 请提供这些详细信息。
    猜你喜欢
    • 2013-04-04
    • 2015-04-24
    • 2011-07-13
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多