在有AS2问题动态加载声音 [英] load sound dynamically in as2 having problem

查看:268
本文介绍了在有AS2问题动态加载声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要加载的声音放置在声音文件夹中。
 code是

I want to load sound placed in sounds folder. Code is

var my_sound = new Sound();
my_sound.loadSound("sounds/sound1.mp3");

my_sound.onLoad = function(success:boolean){

     if(success){
        my_sound.start();
      }
}

此播放声音时,闪光灯打开,pressing Ctrl + Enter(测试影片)。

This plays sound when flash is open and pressing CTRL+ENTER(Test Movie).

但是,当我们播放SWF也不会播放声音。

but when we plays the swf it won't play sound.

对于这个问题,我发现了一个解决方案。

for this problem i found one solution.

我掠走的onLoad功能。和测试影片。现在相反的事情happend。

i made off onLoad function. and the Test Movie. Now the opposite things happend.

忽略了最低游玩时preSS Ctrl + Enter(TestMovie);

It dosen't play when press CTRL+ENTER (TestMovie);

但SWF播放它起着。

有没有加载声音的任何其他方式。

Is there any other way of loading sound.

推荐答案

尝试:

var my_sound:Sound = new Sound();
my_sound.onLoad = function(success:Boolean)
{
    if (success)
    {
        my_sound.stop();
    } 
};
my_sound.loadSound("sounds/sound1.mp3", true);

这会尽快它的加载停止声音。
每当你想启动的声音,只是调用这个函数:

This will stop the sound as soon as it's loaded. Whenever you want to start the sound, just call this function:

my_sound.start();

这篇关于在有AS2问题动态加载声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆