AS3已經中Loader與URLLoader是兩個比較容易混淆的類。
Loader: swf,圖片(jpg,png,gif)
URLLoader:文本文件(xml,php,jsp…)
Loader:
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
private function loadComplete(event:Event){
trace("done");
addChild(loader);
}
URLLoader:
xmlLoader.dataFormat=URLLoaderDataFormat.TEXT;
xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
private function xmlLoaded(event:Event
{
try {myXML = XML(event.target.data);area.text=myXML;}
catch (e:TypeError) {area.text="Load faild:n"+e.message;}
}