我正在构建一个AIR ActionScript 3.0应用程序。每当我在电脑上尝试它时,通过执行Command + Enter并测试电影,该应用程序将正常工作,两个电影剪辑之间的冲突工作正常。但是,当我尝试发布它并获得相应的apk时,该应用程序将正常运行,但不会发生碰撞!仿佛这两个电影剪辑只是飞到彼此之上,没有任何反应!在PC上,它的工作完美!我是AS3的新手,所以任何人都可以指出我哪里出错了?这是我用于碰撞的代码:
function ifHitAct(e:Event):void
{
for each (var obstacle in runNow.manyObs)
{
//trace("the obstacle Index Created is" , parent.getChildIndex(runNow.obstacle));
//parent.setChildIndex(runNow.obstacle ,1)
if (MC1.hitTestObject(obstacle))
{
hit.play(0);
runNow.manyObs.splice(runNow.manyObs.indexOf(obstacle), 1);
//this.removeChild(obstacle);
score++;
scoreField.text = String(score);
obstacle.alpha = 0;
}
}
}
答案 0 :(得分:1)
[Embed(source='/hit.mp3')]
private var MySound : Class;
private var sound : Sound;
然后在需要播放音乐时启动var:
function ifHitAct(e:Event):void
{
//
for each (var obstacle in runNow.manyObs)
{
if (MC1.hitTestObject(obstacle))
{
sound = (new MySound()) as Sound;
sound.play(0);
runNow.manyObs.splice(runNow.manyObs.indexOf(obstacle), 1);
score++;
scoreField.text = String(score);
obstacle.alpha = 0;
}
}
}
它将完美地运作。