如何发挥ActionScript 3的声音,是不是在同一个目录中的SWF?声音、目录中、在同一个、ActionScript

2023-09-08 11:32:39 作者:鱼在水里哭

我有一大堆的外部声音到SWF的项目​​。我想打他们,但任何时候我尝试加载一个新的URL到它失败,无论是错误#2068:无效的声音的声音对象或引发一个ioError在错误#2032流错误

I have a project with a bunch of external sounds to a SWF. I want to play them, but any time I attempt load a new URL into the sound object it fails with either "Error #2068: Invalid Sound" or raises an ioError with "Error #2032 Stream Error".

//试图与pfixed与路径$ P $的http:// ..文件:// ..// ..和..)

// Tried with path prefixed with "http://.." "file://.." "//.." and "..")

VAR路径:字符串=HTTP://../assets/the_song.mp3;

var path:String = "http://../assets/the_song.mp3";

VAR URL:的URLRequest =新的URLRequest(路径);

var url:URLRequest = new URLRequest( path );

VAR的声音:声音=新的声音();

var sound:Sound = new Sound();

sound.addEventListener(IOErrorEvent.IO_ERROR,事件。ioErrorHandler);

sound.addEventListener( IOErrorEvent.IO_ERROR, ioErrorHandler);

sound.addEventListener(SecurityErrorEvent.SECURITY_ERROR,secHandler);

sound.addEventListener( SecurityErrorEvent.SECURITY_ERROR, secHandler);

调用Sound.load(URL);

sound.load(url);

推荐答案

嗯,我只是把一个MP3目录中做过一个试验: soundTest /资产/ Song.mp3的然后创建一个SWF调用MP3另一个目录: soundTest / SWF文件/ soundTest.swf 键,当我使用 VAR路径:字符串=../资产/ Song.mp3的; 然后再编译没有错误

Well, I've just done a test by putting an mp3 in a directory: soundTest/assets/song.mp3 then creating a swf that calls the mp3 in another directory: soundTest/swfs/soundTest.swf and when I use var path:String = "../assets/song.mp3"; then it compiles with no errors.

什么是您的实际目录结构?

What is your actual directory structure?

 
精彩推荐