得添加監聽
var context:LoaderContext = new LoaderContext();
context.checkPolicyFile = true;
var url:URLRequest = new URLRequest("gallery/test.swf");
var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
myLoader.addEventListener(AsyncErrorEvent.ASYNC_ERROR, errorHandlerAsyncErrorEvent);
myLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandlerIOErrorEvent);
myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandlerSecurityErrorEvent);
myLoader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, infoIOErrorEvent);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
myLoader.load(url,context);
myLoader.load(url);
function progressListener (e:ProgressEvent):void{
trace("Downloaded " + e.bytesLoaded + " out of " + e.bytesTotal + " bytes");
}
function initHandler(e:Event):void{
trace('load init');
}
function errorHandlerErrorEvent(e:ErrorEvent):void{
trace('errorHandlerErrorEvent ' + e.toString());
}
function infoIOErrorEvent(e:IOErrorEvent):void{
trace('infoIOErrorEvent ' + e.toString());
}
function errorHandlerIOErrorEvent(e:IOErrorEvent):void{
trace('errorHandlerIOErrorEvent ' + e.toString());
}
function errorHandlerAsyncErrorEvent(e:AsyncErrorEvent) :void{
trace('errorHandlerAsyncErrorEvent ' + e.toString());
}
function errorHandlerSecurityErrorEvent(e:SecurityErrorEvent):void{
trace('errorHandlerSecurityErrorEvent ' + e.toString(
));
}
function onLoadComplete(e:Event):void{
trace('onLoadComplete');
}
添加代碼格式化你的代碼。只需在行的開頭添加4個空格以使其代碼格式化即可。 – prototypical 2011-05-25 22:02:41
在調試器中測試時是否發生本地錯誤?另外,這個代碼是在.swf中,由另一個.swf加載還是加載到一個html頁面中?另外,請檢查那裏列出的url路徑的大小寫,以確保它匹配正確。 – prototypical 2011-05-25 22:08:03