【发布时间】:2022-06-19 21:57:49
【问题描述】:
我有来自图书馆的背景音乐,有什么想法可以通过单击按钮来解决此代码以更改它吗?
var BeachBall: CrashBash_BeachBall = new CrashBash_BeachBall();
var BrickDive: LEGOIsland2_BrickDive = new LEGOIsland2_BrickDive();
var BloocheepOcean: MarioHoops_BloocheepOcean = new MarioHoops_BloocheepOcean();
var Underwater: MarioTeachesTyping2_Underwater = new MarioTeachesTyping2_Underwater();
var UnderPressure: CrashBandicootNST_UnderPressure = new CrashBandicootNST_UnderPressure();
var CalmWaters: DireDireDocks_CalmWaters = new DireDireDocks_CalmWaters();
var Level1: TreasureCove_Level1 = new TreasureCove_Level1();
var Level2: TreasureCove_Level2 = new TreasureCove_Level2();
var Level3: TreasureCove_Level3 = new TreasureCove_Level3();
var music: Array = new Array(CalmWaters, BloocheepOcean, UnderPressure, Underwater, BeachBall, BrickDive, Level1, Level2, Level3);
// Changing the Background Music
music_btn.addEventListener(MouseEvent.CLICK, on_pressMusic);
music[Math.floor(Math.random()*music.length)].play();
}
游戏背景更新:
if(!sound){
sound_channel = CalmWaters.play(0, int.MAX_VALUE);
sound_channel.soundTransform = new SoundTransform(0.4);
}
错误:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at BlowfishPong_fla::MainTimeline/on_pressMusic()[BlowfishPong_fla.MainTimeline::frame27:205]
【问题讨论】:
标签: arrays actionscript-3 flash audio background-music