ITeye博客

什么时候使用e.target.content和e.target as MovieClip?

china34420 · 2010-08-06 14:28 · ActionScript 3.0 · 编程语言 · Markdown

只是自己理解和使用习惯.... content : DisplayObject 包含使用 load() 或 loadBytes() 方法加载的 SWF 文件或图像(JPG、PNG 或 GIF)文件的根显示对象。

下以情况使用e.target.content:想得到由Loader加载的显示对像时 如

var url:URLRequest=new URLRequest("路径")
var loader:Loader=new Loader;
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
private function loadComplete(e:Event):void
		{
                   //此处可得到loader的引用:loader的显示对像
		   var  _tempMc:MovieClip = e.target.content;
		
		}

以下情况使用e.target as MovieClip:想得到监听对像的引用

mc.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(e:MouseEvent){
    //此处可得到mc的引用
    var mc1:MovieClip=e.target as MovieClip;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。