topical media & game development
actionscript-video-09-transitions-pro-VideoMC-notworking.ax
actionscript-video-09-transitions-pro-VideoMC-notworking.ax
[swf]
flex
package FlashVideoPro
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
public class VideoMC extends MovieClip {
var nc:NetConnection;
var myVid:Video;
var ns:NetStream;
var vidName:String;
function VideoMC(vidName:String) {
var nc:NetConnection = new NetConnection();
var myVid:Video = new Video(240, 180);
// Construct NetConnection
nc.connect(null);
//controlVid(vidName);
//ns.play(vidName);
}
public function set controlVid(vidName:String):void {
var ns:NetStream = new NetStream(nc);
// Construct NetStream and connect to flow through NetConnection
ns.bufferTime = 3;
// Flash is looking for an onMetaData method, route all calls to an object
var metaObject:Object = new Object();
metaObject.onMetaData = onMetaData;
// Route all onMetaData calls on NetStream to the metaObject
ns.client = metaObject;
myVid.attachNetStream(ns);
addChild(myVid);
ns.play(vidName);
myVid.x = 100;
myVid.y = 100;
}
public function set stopVid(vidName:String):void {
ns.close();
}
private function onMetaData(data:Object):void {
// Satisfies Flash's need to send metadata with Flash Video
// This is considered to be a bug and may be fixed in the final AS3 release
}
}}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.