【发布时间】:2012-04-13 10:15:25
【问题描述】:
我在语法正确时遇到了一些麻烦。
我有一个影片剪辑,当它接触其他影片剪辑时,它会向数组添加声音。 我有一个停止按钮,而不是我想删除栏的事件侦听器并发送回原始位置。
我的代码是:
//event listener for the start button
playy.addEventListener(MouseEvent.CLICK, mouseClick2);
function mouseClick2(event:MouseEvent):void
{
bar.addEventListener(Event.ENTER_FRAME, onEnter);
}
//Add event listener for the stop button
stopp.addEventListener(MouseEvent.CLICK, mouseClick3);
//when clicked remove listener send back to position
function mouseClick3(event:MouseEvent):void
{
bar.removeEventListener(MouseEvent.CLICK, mouseClick3);
function mouseClick3(evt:Event):void
{
if(bar.x > 780)
{
bar.x = 215;
}
}
}
function onEnter(evt:Event):void
{
bar.x += 1;
if(bar.x > 780)
{
bar.x = 215;
}
for(var i:int=0; i<blocks.length;i++)
{
if (bar.hitTestObject(blocks[i]))
{
blocks[i].start();
}
else
{
blocks[i].stopSound();
}
}
}
【问题讨论】:
-
您遇到的一个问题是
function mouseClick3()嵌套在另一个function mouseClick3()中。
标签: flash actionscript flash-cs5 event-listener