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

只是自己理解和使用习惯....
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;
}

你可能感兴趣的:(java)