AS3 - playing video within a loaded swf

﹥>﹥吖頭↗ 提交于 2019-12-11 12:37:11

问题


My file structure is this:
main.swf
/swf/child.swf
/video/testvideo.flv

When I compile the child.swf by itself, it loads and plays video just fine (using netStream.play(../video/testvideo.flv).

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.

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.


回答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.



来源:https://stackoverflow.com/questions/1358728/as3-playing-video-within-a-loaded-swf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!