我在Haxe中創建一個動作視頻播放器並避免asyncError我試圖創建一個自定義對象。我如何做到這一點是Haxe?如何在Haxe中創建一個動作對象
client屬性指定調用回調方法的對象。默認對象是正在創建的NetStream對象。如果將客戶端屬性設置爲另一個對象,則將在該另一個對象上調用回調方法。
這是我的代碼。
public function new()
{
super();
trace("video");
//initialize net stream
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
buffer_time = 2;
ns.bufferTime = buffer_time;
//Add video to stage
myVideo = new flash.media.Video(640, 360);
addChild(myVideo);
//Add callback method for listeing on NetStream meta data
client = new Dynamic();
ns.client = client;
client.onMetaData = metaDataHandler;
}
public function playVideo(url:String)
{
urlName = new String(url);
myVideo.attachNetStream(ns);
ns.play(urlName);
ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
}
function netstat(stats:NetStatusEvent)
{
trace(stats.info.code);
}
function metaDataHandler(infoObject:Dynamic)
{
myVideo.width = infoObject.width;
myVideo.height = infoObject.height;
}
有你嘗試使用{}? as client = {}; – Waneck 2012-03-26 21:20:52