我需要在我的项目上加载一个声音文件,但是它必须在执行code.One开始时只加载一次,这样做的方法是使用CSS,但是CSSis消耗了很高的比特率,所以我怎么做呢?
发布于 2013-10-19 11:16:54
我认为您必须阅读AS3 doc:US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html
如您所见,您只需创建一个新的声音对象:
var mySound:Sound = new Sound( new URLRequest('http://url.to.your.sound') );或者,如果您想等待加载完成:
// create sound object
var mySound:Sound = new Sound();
// listen for the end of the loading
mySound.addEventListener( Event.COMPLETE, _onSoundLoaded );
// maybe you want to track the progress of the loading
mySound.addEventListener( Event.COMPLETE, _onSoundLoading );
// start loading
mySound.load( new URLRequest('http://url.to.your.sound') );
// the loading is complete
function _onSoundLoaded(e:Event):void
{
// play the sound
mySound.play();
}
// the loading progress
function _onSoundLoading(e:Event):void
{
// trace the progression
trace( mySound.bytesTotal / mySound.bytesLoaded );
}希望这能有所帮助。
发布于 2019-02-14 06:37:03
首先在库中添加声音,并将其命名为mysound1并查看此代码;
var mysound:mysound1 = new mysound1 ();
var mychannel:SoundChannel = mysound1.play();当你的游戏完成后,输入以下代码:-
mychannel.stop();https://stackoverflow.com/questions/19445742
复制相似问题