views:

331

answers:

1

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.

A: 

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.

thehiatus