1

我的文件结构是这样的:
main.swf
/swf/child.swf
/video/testvideo.flv

当我自己编译 child.swf 时,它可以很好地加载和播放视频(使用 netStream.play(../video/testvideo.flv)。

但是,当我编译 main.swf(有时会加载 child.swf)时,尝试播放视频时出现此错误:

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

我应该如何配置路径以便在编译主 swf 时可以看到它?我尝试将路径更改为仅 video/testvideo.flv,但仍然出现相同的错误。

4

1 回答 1

1

The problem is that relative path is based on the parent movie clip, so when you test child.swf, the start path is /swf/ and when you test main.swf, the start path is /. If you want the video to play for both, you will need to do a little test. Something like this:

var rootPath:String = (root==this) ? "../" : "./";
netStream.play(rootPath + "video/testvideo.flv");

That way if you're testing child.swf, root == this, so it will use ../video/testvideo.flv as the path. If you're testing main.swf, root != this, so it will use ./video/testvideo.flv as the path.

于 2009-09-29T19:54:16.303 回答