【问题标题】:AS3 Interactive Story Choice ButtonAS3 互动故事选择按钮
【发布时间】:2014-05-03 04:13:28
【问题描述】:

我承认,我是 AS3 的 n00b。我的问题是这个。我正在制作一部互动小说,我使用movieClip 作为选择按钮,因为它们提供了更多的控制。我试图让他们响应鼠标事件,以便通过转到 ChoiceBtn 的movieClip 内的另一个帧来对用户做出更多响应(如突出显示)。这是我想出的代码,flash 的行为就像它不存在一样。

ChoiceBtn1.addEventListener(MouseEvent.MOUSE_OVER, mouse_Over);
ChoiceBtn1.addEventListener(MouseEvent.MOUSE_DOWN, mouse_Down);
ChoiceBtn1.addEventListener(MouseEvent.MOUSE_OUT, mouse_Out);

ChoiceBtn2.addEventListener(MouseEvent.MOUSE_OVER, mouse_Over);
ChoiceBtn2.addEventListener(MouseEvent.MOUSE_DOWN, mouse_Down);
ChoiceBtn2.addEventListener(MouseEvent.MOUSE_OUT, mouse_Out);

ChoiceBtn3.addEventListener(MouseEvent.MOUSE_OVER, mouse_Over);
ChoiceBtn3.addEventListener(MouseEvent.MOUSE_DOWN, mouse_Down);
ChoiceBtn3.addEventListener(MouseEvent.MOUSE_OUT, mouse_Out);

function mouse_Over (event: MouseEvent):void 
{
    event.target.gotoAndStop(2);
}

function mouse_Down (event: MouseEvent):void 
{
    event.target.gotoAndStop(3);
}

function mouse_Out (event: MouseEvent):void 
{
    event.target.gotoAndStop(1);
}

【问题讨论】:

  • 你的代码非常好。你是什​​么意思“......闪光灯的行为就像它不存在一样。” IT 是什么?

标签: actionscript-3 events button mouse movieclip


【解决方案1】:

您的代码非常好。您已经在属性面板中给出了按钮实例名称:ChoiceBtn1、ChoiceBtn2 和 ChoiceBtn3,对吗?你是什​​么意思“......闪光灯的行为就像它不存在一样。” IT 是什么?

【讨论】:

  • 好吧,当我运行代码并将鼠标悬停在影片剪辑上时,什么也没有发生。没有突出显示或向下箭头的东西,什么都没有。
  • 您正在展示您的代码,但您的代码不是问题所在。展示你的舞台截图怎么样?您的一个按钮的另一个时间线-MovieClips;和另一个属性面板,其中一个 MovieClips 被选中。
  • 另外,在 mouse_Over 函数中添加一个跟踪语句。像这样: trace("this function works") 现在运行代码。您是否在输出面板中获得跟踪?如果是,那么您的movieClips 的时间线有问题。如果没有,那么如果你正确命名了你的电影剪辑,那是不可能的
  • 嘿,所以我听取了您的建议,并查看了时间轴上的设置方式,这就是问题所在。感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-09
  • 1970-01-01
  • 2011-09-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多