Package
{
Import Flash. display. Sprite;
Import Flash. Events. mouseevent;
Import Flash. Media. video;
Import Flash.net. netconnection;
Import Flash.net. netstream;
// Play FLV videos
Public Class Main Extends Sprite
{
VaR Stream: netstream;
Public Function Main (): void
{
// Step 1: create a channel and open the channel
VaR Conn: netconnection = new netconnection ();
Conn. Connect ( Null );
// Step 2: Create a stream processing, and specify the callback function as its own
Stream = new netstream (conn );
VaR OBJ: Object = New Object ();
Stream. Client = OBJ;
// Step 3: Present the video stream and bind the video stream
VaR Video: Video = new video (200,150 );
Video. attachnetstream (Stream );
This. addchild (video );
Stream. Play ("sp. FLV ");
// Use buttons to control video playback and stop
VaR S: SPRITE = new sprite ();
S. Graphics. beginfill (0xff0000 );
S. Graphics. drawrect (0, 0, 50, 50 );
S. Graphics. endfill ();
S. Y = 150;
This. addchild (s );
S. addeventlistener (mouseevent. Click, );
}
Private Function An (EVT: mouseevent): void
{
Stream. togglepause ();
}
}
}