AS3 - 玩在加载的SWF视频 [英] AS3 - playing video within a loaded swf
问题描述
我的文件结构是这样的:
main.swf中
/swf/child.swf
/video/testvideo.flv
My file structure is this:
main.swf
/swf/child.swf
/video/testvideo.flv
当我单独编译child.swf,它加载和播放视频就好了(用的NetStream.play(../视频/ testvideo.flv)。
When I compile the child.swf by itself, it loads and plays video just fine (using netStream.play(../video/testvideo.flv).
然而,当我编译main.swf中,这在某些时候负载child.swf,我得到尝试播放视频的时候这个错误:
However, when I compile the main.swf, which at some point loads child.swf, I get this error when trying to play the video:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
我怎么配置路径,以便它可以当我编译主SWF可以看到?我试图改变路径,只是视频/ testvideo.flv,我仍然得到同样的错误。
How am I supposed to configure the path so that it can be seen when I compile the main swf? I've tried changing the path to just video/testvideo.flv, and I still get the same error.
推荐答案
问题是,相对路径是基于父级影片剪辑,因此,当你测试child.swf,开始路径是/ SWF /当你测试main.swf中,开始路径是/。如果您希望视频为玩,你需要做一个小测试。事情是这样的:
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");
如果您正在测试child.swf这样一来,根==这个
,所以它会使用 ../视频/ testvideo.flv
作为路径。如果你正在测试的main.swf,根!=这个
,所以它会使用 ./视频/ 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.
这篇关于AS3 - 玩在加载的SWF视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!