0
我是AS3的新手,需要一些帮助。在运行时构造变量名称
我有这样的代码来播放不同的音频文件和动态循环他们:
var mIntroLoop = 12495;
var mBattleLoop = 29000;
var currentPlaying;
function playMusic(x):void
{
musicChannel = x.play();
currentPlaying = x;
}
function loopSound(m:Object):Function {
return function(e:Event):void {
musicChannel = m.play(m.toString() + "Loop");
musicChannel.addEventListener(Event.SOUND_COMPLETE, loopSound(currentPlaying));
}
}
playMusic(mIntro);
musicChannel.addEventListener(Event.SOUND_COMPLETE, loopSound(currentPlaying));
正如你可以在代码的顶部看到我有两个变量,mIntroLoop
和mBattleLoop
。
我需要这一行帮助:
musicChannel = m.play(m.toString() + "Loop");
这当然不工作,它的存在只是让你知道我想要做的事。
在该行中,m.play()
需要具有mIntroLoop
或mBattleLoop
的返回值作为参数,具体取决于我当前正在播放的内容。
我已经使用Object属性解决了id。 – Fr0z3n