actionscript-3flashstreamnetstreamnetconnection

AS3 error 2126 NetConnection object must be connected


i had this working previously but has stopped working and i cant remember changing anything I am getting the following error

ArgumentError: Error #2126: NetConnection object must be connected.
at flash.net::NetStream/ctor()
at flash.net::NetStream()
at Classes::AccessCamera/UICompleteHandler()
Cannot display source code at this location.
Debug session terminated.

here is my code fo playing the video:

var conn:NetConnection = new NetConnection();
var stream:NetStream = new NetStream(conn);
var media:MediaPromise = event.data;
trace(media.file.url  + " - " + media.relativePath + " - " +media.mediaType);
parent.addChild(video);
conn.connect(null);
//attach a stream  to the video-object
video.attachNetStream(stream);
stream.client = new MobileClient();
//play the stream
stream.play(media.file.url);

I am stuck on this and cant figure it out any help would be greatly appreciated.


Solution

  • You're supposed to connect NetConnection instance before passing it to NetStream instance.

    See example at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html for more info.