将Flex SWF加载到Flash中的问题

时间:2012-05-07 23:38:34

标签: actionscript-3 flash flex actionscript mxml

我正在尝试将Flex SWF加载到我的Flash SWF中,但它无法正常工作。我收到了这个错误:

Error: Error #2136: The SWF file file:///C|/Program%20Files/Adobe/Adobe%20Fireworks%20CS6/Configuration/Command%20Panels/Texture Panel.swf contains invalid data.

    at _Main_mx_managers_SystemManager/create()
    at mx.managers.systemClasses::ChildManager/initializeTopLevelWindow()
    at mx.managers::SystemManager/initializeTopLevelWindow()
    at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::kickOff()
    at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::preloader_completeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.preloaders::Preloader/timerHandler()
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()

这是我的Flash SWF代码:

package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.*;
    import adobe.utils.*;
    import flash.external.ExternalInterface;
    import flash.display.Loader;
    import flash.net.URLRequest;

    public class Main extends 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);

            var myLoader:Loader = new Loader(); addChild(myLoader);

            function systemManagerHandler(event:Event):Boolean { event.preventDefault(); return false; }

            myLoader.addEventListener("mx.managers.SystemManager.isBootstrapRoot", systemManagerHandler);
            myLoader.addEventListener("mx.managers.SystemManager.isStageRoot", systemManagerHandler);

            myLoader.load(new URLRequest("Texture Panel.swf"));
        }

    }

}

我喜欢这方面的任何帮助。提前谢谢!

1 个答案:

答案 0 :(得分:1)

来自andy moore的

Tip

1)Flash:文件>新> Flash AS3.0文件

2)复制旧FLA中的整个“库”

3)将整个“库”粘贴到新的FLA

4)删除旧文件,这是神奇的毒药