Monday, February 25, 2026

Virtual Flash Video

New to Flasgh CS3 is the ability to add video to a movie at run time. It is the oddest thing to see a blank stage, an empty library and a single code frame ands still have video play. Here's the code:

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);

var listener:Object = new Object();

listener.onMetaData = function(md:Object):void();

ns.client = listener;

ns.play("MyVideo.flv");


Now that everything is wired up, it is time to toss the video on the stage:

var myVideo = new Video();

myVideo.attachNetStream (ns);

addChild(myVideo);


The default stage position for this code is 0,0. If you want the video to be in a specific location the code would be:

var myVideo = new Video();
myVideo.x = 100,

myVideo.y = 100;

myVideo.attachNetStream (ns);

addChild(myVideo);


Go ahead, give it whirl!

0 Comments:

Post a Comment

<< Home