帮帮我,我用的是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
可以很好地用于闪存。下面是我的朋友代码:
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.
发布于 2017-08-06 20:27:47
我只是在youtube上看,我漏了一步。在库中,打开music.mp3
的属性并为其指定类名。
所以,我们可以使用这个var Audio:musik=new musik();
调用这个类。然后,创建声音通道。至少,函数可以播放并停止使用以下内容:
//play
chan=Audio.play();
// stop
chan.stop();
https://stackoverflow.com/questions/45536035
复制相似问题