Ap. As the code is as follows:
Package test {
The import flash. Media. Video;
The import flash.net.NetConnection;
The import flash.net.NetStream;
The import flash.events.Net StatusEvent;
The import flash. Display. Sprite;
The import flash. Events. Event
The public class extends sp Sprite {
Var theVideo: Video;//video object
Var theNet: NetConnection;//connection object
Var theNets: NetStream;//data stream objects
The public function (sp) {
}
The public function InitVars () : void {
Var theVideo=new Sprite ();
TheVideo=new Video (1920, 1080);
TheVideo. X=theVideo. Y=0;
AddChild (theVideo);
TheNet=new NetConnection ();
TheNet. Connect (null);
TheNets=new NetStream (theNet);
TheNets. Client=this;
TheVideo. AttachNetStream (theNets);
}
The public function LoadMovie () : void {
TheNets. Play (" adornment picture always. Mp4 ");
TheNets. AddEventListener (NetStatusEvent.NET _STATUS, onStatusHandler);
}
The public function onStatusHandler (e: NetStatusEvent) : void {
Var evtCode: String=e.i show nfo. Code;
The switch (evtCode) {
Case NetStream. Play. "Start" :
break;
Case NetStream. Play. "Empty" :
break;
Case NetStream. Play. "Full" :
break;
Case "NetStream. Play. StreamNotFound" :
break;
Case "NetStream. Play. Stop" :
RemoveVedio ();
break;
}
}
//unloading video
The public function RemoveVedio () : void {
TheNets. Pause ();
TheNets. The dispose ();
TheNet=null;
TheVideo. The clear ();
The removeChild (theVideo);
}
}
}
The code in the fla is as follows:
The import test. Sp;
Var onesp: sp=new (sp);
Onesp. LoadMovie ();
Onesp. InitVars ();
When running in the output panel display is as follows:
TypeError: Error # 1009: unable to access attributes or methods of empty object references,
The at test: : sp/LoadMovie ()
At video document 2 _fla: : MainTimeline/frame1 ()
CodePudding user response: