Well, first you want the connection to succeed, only then you can play the video. Listen for the status event on the NetConnection object and start playing the video in the event handler.
See the example here: http://livedocs.adobe.com/flex/2/langref/flash/net/NetConnection.html On 4/24/07, arokyzxc <[EMAIL PROTECTED]> wrote: > hello all > i wrote codes to streaming flv from fms,but i got the connection error. > here is my connection code: > public function connection():void{ > var video :Video = new Video(160,120); > var nc :NetConnection = new NetConnection(); > nc.connect("rtmp://localhost/videodisplay/greenday.flv"); > > var stream:NetStream = new NetStream(nc); > > stream.play("greenday.flv"); > > video.attachNetStream(stream); > video.width = 160; > video.height = 120; > canvas.addChild(video); > } > i got following error report : > ArgumentError: Error #2126: must connect NetConnection object ¡£ > at flash.net::NetStream/flash.net:NetStream::construct() > at flash.net::NetStream$iinit() > at HelloFms/connection() > at HelloFms/___Application1_creationComplete() > at > flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction() > at flash.events::EventDispatcher/dispatchEvent() > at mx.core::UIComponent/dispatchEvent() > at mx.core::UIComponent/set initialized() > at mx.managers::LayoutManager/::doPhasedInstantiation() > at Function/http://adobe.com/AS3/2006/builtin::apply() > > Error #2044: unhanded NetStatusEvent:¡£ level=error, > code=NetConnection.Connect.Failed > at HelloFms/connection() > at HelloFms/___Application1_creationComplete() > at > flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction() > at flash.events::EventDispatcher/dispatchEvent() > at mx.core::UIComponent/dispatchEvent() > at mx.core::UIComponent/set initialized() > at mx.managers::LayoutManager/::doPhasedInstantiation() > at Function/http://adobe.com/AS3/2006/builtin::apply() > at mx.core::UIComponent/::callLaterDispatcher2() > at mx.core::UIComponent/::callLaterDispatcher() > does anybody ever face these problem ? i will appreciate if somebody > give me some suggestion . > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > > > >