ActionScript 3 - 声音 mp3 无法正常播放
ActionScript 3 - sound mp3 is not played without error
帮帮我,我用的是Adobe Flash CS3 Professional
// i have try using this import, but still not work
/*import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
*/
// here is the code
var req:URLRequest=new URLRequest("music.mp3");
var snd:Sound=new Sound();
snd.load(req);
var chan:SoundChannel=snd.play();// not work using 'snd.play(1);' too
chan.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
function onPlaybackComplete(event:Event){
trace("Musik Complete");
}
当我运行swf或ctrl+enter
时,输出Musik Complete
没有任何声音播放,但动画仍然播放。对于动画,我只是创建简单的孪生运动。
我在这个目录上工作
C:/flash/example.fla
C:/flash/example.swf
C:/flash/music.mp3
我也尝试将 music.mp3
导入到库中。
注意:我从朋友那里得到的例子(.swf、.fla、.mp3)。我玩我朋友分享的 .swf 并工作,但当我尝试自己创建时,却无法工作。所以,我认为 music.mp3
适合用于 Flash。这是我的朋友代码:
var Audio:musik = new musik();
var chan:SoundChannel = new SoundChannel();
// play
chan=Audio.play();
// stop
chan.stop();
// i am so confuse i run my friend project and work fine (sound and other), if i write from scrap even i write the same code, there is an error, and this the error:
// 1046: Type was not found or was not a compile-time constant: musik.
// 1180: Call to a possibly undefined method musik.
我只是在 youtube 上看,我错过了一步。
在库中,打开 music.mp3
的属性并为其命名 class。
因此,我们可以使用此 var Audio:musik=new musik();
调用 class。
然后,创建声音通道。
至少,播放和停止使用这个功能:
//play
chan=Audio.play();
// stop
chan.stop();
帮帮我,我用的是Adobe Flash CS3 Professional
// i have try using this import, but still not work
/*import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
*/
// here is the code
var req:URLRequest=new URLRequest("music.mp3");
var snd:Sound=new Sound();
snd.load(req);
var chan:SoundChannel=snd.play();// not work using 'snd.play(1);' too
chan.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
function onPlaybackComplete(event:Event){
trace("Musik Complete");
}
当我运行swf或ctrl+enter
时,输出Musik Complete
没有任何声音播放,但动画仍然播放。对于动画,我只是创建简单的孪生运动。
我在这个目录上工作
C:/flash/example.fla
C:/flash/example.swf
C:/flash/music.mp3
我也尝试将 music.mp3
导入到库中。
注意:我从朋友那里得到的例子(.swf、.fla、.mp3)。我玩我朋友分享的 .swf 并工作,但当我尝试自己创建时,却无法工作。所以,我认为 music.mp3
适合用于 Flash。这是我的朋友代码:
var Audio:musik = new musik();
var chan:SoundChannel = new SoundChannel();
// play
chan=Audio.play();
// stop
chan.stop();
// i am so confuse i run my friend project and work fine (sound and other), if i write from scrap even i write the same code, there is an error, and this the error:
// 1046: Type was not found or was not a compile-time constant: musik.
// 1180: Call to a possibly undefined method musik.
我只是在 youtube 上看,我错过了一步。
在库中,打开 music.mp3
的属性并为其命名 class。
因此,我们可以使用此 var Audio:musik=new musik();
调用 class。
然后,创建声音通道。
至少,播放和停止使用这个功能:
//play
chan=Audio.play();
// stop
chan.stop();