闪电崩盘时加载外部SWF(与code例如这阵子) [英] flash crash when loading external swf (with code example this time around)

查看:209
本文介绍了闪电崩盘时加载外部SWF(与code例如这阵子)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在FlashDevelop中创建一个AS3项目。它的目标的Flash Player 10。 运行此code时,我有一个令人不安的问题:

This is a AS3 project created in FlashDevelop. It targets flash player 10. I have a disturbing problem when running this code:

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() - 方法。所有这一切都显示在我的输出窗口:

Now, what I can gather from the debug window, what happens is that the swf restarts itself and just ends up in a loop when i try to call the addChild()-method. All that is shown in my output window is:

[SWF] C:\svn\Development\TestProject\bin\loadIn.swf - 1 797 bytes after decompression.
application/x-shockwave-flash
true
true
10
[object Main]

任何想法可能创造这样一个奇怪的循环和错误?从来就一直试图整天来解决它。也许某种在FlashDevelop中设置或参数的MXMLC编译器?

Any ideas what could create such a strange loop and error? I´ve been trying to solve it all day. Maybe some kind of settings in FlashDevelop or parameters to the MXMLC compiler?

为感谢所有答案!

推荐答案

如果他们有相同的名字,你就不能或不想改名字,尝试一次装入一个新的ApplicationDomain中的文件中的LoaderContext您的URLRequest的:的http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/system/LoaderContext.html 这应该解决任何冲突。

If they do have the same name and you're not able or don't want to change the name, try loading the file with a new applicationDomain in the LoaderContext of your URLRequest: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/system/LoaderContext.html That should resolve any conflicts.

这篇关于闪电崩盘时加载外部SWF(与code例如这阵子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆