Skip to main content
Participant
September 30, 2009
Answered

stopping a netstream

  • September 30, 2009
  • 1 reply
  • 405 views

I have managed to compile a script that pulls in an external video file, using netstream but now need to unload, or stop that video and start a new one.  The code I have used to load is:

//creates an object in which to put metaData to be handled later
var customClient:Object = new Object();
customClient.onMetaData = metaDataHandler;

//establishes net connection to load video via web or local file
var nc:NetConnection = new NetConnection();
nc.connect(null);

//creates a stream for the video and locates file
var ns:NetStream = new NetStream(nc);
ns.client = customClient;
ns.play("filmTest1.flv");

var myVideo:Video = new Video();
myVideo.attachNetStream(ns);
addChild(myVideo);

//positions video using metaData from video
function metaDataHandler(infoObject:Object):void {
    myVideo.width = infoObject.width;
    myVideo.height = infoObject.height;
}

I am really struggling with grasping this so any help would be greatly appreciated.  I am using CS3, and all the tutorials are for CS4!!

kerrie.suteu@theherbert.org

This topic has been closed for replies.
Correct answer kglad

use:

ns.close();

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 30, 2009

use:

ns.close();

Participant
October 1, 2009

thank-you so much you've saved me a lot of time

kglad
Community Expert
Community Expert
October 1, 2009

you're welcome.