这是在FlashDevelop中创建的AS3项目。 它的目标是Flash播放器10.我有这段代码运行时,一个令人不安的问题:
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
public class Main extends MovieClip
{
private var loader:Loader;
private var sprite:Sprite;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init); }
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingDone);
loader.load(new URLRequest('loadIn.swf')); // error occurs when loading this file.
//loadIn.swf is compiled with all the code in this file but with the loader-parts commented out...
// just a Adobe Flash created graphic, no problems loading this one
//loader.load(new URLRequest('waitingPopup.swf'));
//sprite = new Sprite();
//sprite.graphics.beginFill(0xFF0000);
//sprite.graphics.drawRect(0, 0, 490, 356);
//sprite.graphics.endFill();
//addChild(sprite);
}
private function loadingDone(e:Event):void {
trace(loader.contentLoaderInfo.contentType); // application/x-shockwave-flash
trace(loader.contentLoaderInfo.parentAllowsChild); // true
trace(loader.contentLoaderInfo.sameDomain); // true
trace(loader.contentLoaderInfo.swfVersion); // 10
trace(loader.contentLoaderInfo.content); // [Object Main]
//this is were everything goes south
addChild(e.target.content);
}
}
}
现在,我可以从调试窗口聚集,会发生什么情况是,SWF自行重启,只是结束了一个循环,当我尝试调用addChild()
-方法。 所有这一切都显示在我的输出窗口是:
[SWF] C:\svn\Development\TestProject\bin\loadIn.swf - 1 797 bytes after decompression.
application/x-shockwave-flash
true
true
10
[object Main]
任何想法可能创造这样一个奇怪的循环和错误? 从来就一直在试图整天来解决它。 也许某种在FlashDevelop中或设置参数的MXMLC编译器?
感谢所有的答案!