Import flash. Events. netstatusevent;
Import flash. Media. video;
Import flash.net. netconnection;
Import flash.net. netstream;
Private var mync: netconnection;
Private var client: object;
Private var videostream: netstream;
Private var video: video;
Private var videourl: string;
Mync = new netconnection ();
Mync. Connect (null );
Client = new object ();
Videostream = new netstream (mync );
Video = new video ();
Video. width = 350;
Video. Height = 200;
Video. x = 665;
Video. Y = 190;
Sprite. addchild (video );
Video. attachnetstream (videostream );
Videostream. Play (videourl );
Videostream. Client = client;
Videostream. addeventlistener (netstatusevent. net_status, netstatushandler );
Private function netstatushandler (Event: netstatusevent): void
{
Switch (event.info. Code)
{
Case "netconnection. Connect. Success ":
Connectstream ();
Break;
Case "netstream. Play. streamnotfound ":
Trace ("unable to locate video:" + videourl );
Break;
Case "netstream. Buffer. Full ":
Break;
Case "netstream. Play. Stop ":
Connectstream ();
Break;
}
}
Private function connectstream (): void
{
Videostream. Pause ();
Videostream. Seek (0 );
Videostream. Resume ();
}