2010-12-09 38 views
0

請幫幫忙,如何使netEvent工作編譯閃光,比如我甚至不能讓Macromedia的示例工作:ActionScript編譯MTASC和活動

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

ns.onMetaData = function(infoObject:Object) { 
    for (var propName:String in infoObject) { 
     trace(propName + " = " + infoObject[propName]); 
    } 
}; 

ns.play("http://www.helpexamples.com/flash/video/water.flv"); 

它必須返回元信息,但好像沒有事件被調用。 我在做什麼錯?

謝謝!

回答

0

這是對Adobe的文檔:

package { 
import flash.display.Sprite; 
import flash.events.NetStatusEvent; 
import flash.events.SecurityErrorEvent; 
import flash.media.Video; 
import flash.net.NetConnection; 
import flash.net.NetStream; 
import flash.events.Event; 

public class NetConnectionExample extends Sprite { 
    private var videoURL:String = "Video.flv"; 
    private var connection:NetConnection; 
    private var stream:NetStream; 

    public function NetConnectionExample() { 
     connection = new NetConnection(); 
     connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 
     connection.addEventListener(SecurityErrorEvent.SECURITY_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("Stream not found: " + videoURL); 
       break; 
     } 
    } 

    private function securityErrorHandler(event:SecurityErrorEvent):void { 
     trace("securityErrorHandler: " + event); 
    } 

    private function connectStream():void { 
     stream = new NetStream(connection); 
     stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 
     stream.client = new CustomClient(); 
     var video:Video = new Video(); 
     video.attachNetStream(stream); 
     stream.play(videoURL); 
     addChild(video); 
    } 
} 
} 

class CustomClient { 
public function onMetaData(info:Object):void { 
    trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate); 
} 
public function onCuePoint(info:Object):void { 
    trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type); 
} 
} 

我看來像你缺少你發佈的代碼相當多,你不會得到你要尋找的缺少必需的設置代碼。