| |
Action Script - Loading Streaming Video
Place this script on the frame in which the information is to be loaded. Create a movie clip called "videoContainer" and inside place an embedded video clip (scaled to the desired size of the video) and call it "myVideo." The first thing this script does is makes the video visibility false until you need to start the video. Fill in the names of the start button and the path to your .flv file. The "startButton" then sets the current movie path to the variable "currentMovie" and then calls the "initializeVideo" function. This function connects to the video stream, starts to buffer it, and then calls the "videoActivate" function. The buffer time here is 5 seconds. This time can be adjusted to get the best results for your bandwidth situation. Finally the "vide Activate" button sets the visibility of the video back to true and loads the "currentMovie" into the "NetStream."
function videoActivate () {
videoContainer._visible=true;
myNetStream.play(currentMovie);
}
var myNetConn:NetConnection;
var myNetStream:NetStream;
var videoLV:LoadVars;
var currentMovie
function initializeVideo() {
myNetConn = new NetConnection();
myNetConn.connect(null);
myNetStream = new NetStream(myNetConn);
videoContainer.myVideo.attachVideo(myNetStream);
myNetStream.setBufferTime(5);
videoActivate();
}
startButton.onRelease = function() {
currentMovie="YOUR MOVIE PATH"
initializeVideo()
}
|