Archonius
06-26-2009, 12:47 PM
Hey, im creating a portfolio website that primarily uses flv videos for graphics. For example, if you click to go to another section of the website a video plays that actually walks you to that area. What I want to do is be able to load a different video when a button is clicked in the exact same place as the old one.
I currently have a working class that plays a video
package {
import flash.display.Sprite;
import flash.events.*;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class flvVideo extends Sprite {
private var flvName:String = "flvs/Altris video.flv";
private var _connection:NetConnection;
private var _stream:NetStream;
public function flvVideo() {
_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_ST ATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SE CURITY_ERROR, securityErrorHandler);
_connection.connect(null);
}
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: " + flvName);
break;
}
}
private function connectStream():void {
var _stream:NetStream = new NetStream(_connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS , netStatusHandler);
_stream.addEventListener(AsyncErrorEvent.ASYNC_ERR OR, asyncErrorHandler);
var video:Video = new Video();
video.attachNetStream(_stream);
_stream.play(flvName);
addChild(video);
}
private function securityErrorHandler(event:SecurityErrorEvent):voi d {
trace("securityErrorHandler: " + event);
}
private function asyncErrorHandler(event:AsyncErrorEvent):void {
// ignore AsyncErrorEvent events.
}
}
}
I want to some how be able to change the variable flvName on the click of a button on my stage and recall the class to change the video. If you can think of an alternate way of doing what i need to do id love to hear it.
I am utterly lost and really need the site up and going so any help is much appreciated. Ive already posted on various other sites and people just seem to avoid my post.
I currently have a working class that plays a video
package {
import flash.display.Sprite;
import flash.events.*;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class flvVideo extends Sprite {
private var flvName:String = "flvs/Altris video.flv";
private var _connection:NetConnection;
private var _stream:NetStream;
public function flvVideo() {
_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_ST ATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SE CURITY_ERROR, securityErrorHandler);
_connection.connect(null);
}
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: " + flvName);
break;
}
}
private function connectStream():void {
var _stream:NetStream = new NetStream(_connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS , netStatusHandler);
_stream.addEventListener(AsyncErrorEvent.ASYNC_ERR OR, asyncErrorHandler);
var video:Video = new Video();
video.attachNetStream(_stream);
_stream.play(flvName);
addChild(video);
}
private function securityErrorHandler(event:SecurityErrorEvent):voi d {
trace("securityErrorHandler: " + event);
}
private function asyncErrorHandler(event:AsyncErrorEvent):void {
// ignore AsyncErrorEvent events.
}
}
}
I want to some how be able to change the variable flvName on the click of a button on my stage and recall the class to change the video. If you can think of an alternate way of doing what i need to do id love to hear it.
I am utterly lost and really need the site up and going so any help is much appreciated. Ive already posted on various other sites and people just seem to avoid my post.