2010-12-09 47 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); 
} 
} 

我看来像你缺少你发布的代码相当多,你不会得到你要寻找的缺少必需的设置代码。