加载外部SWF会导致“无法找到资源包消息”错误

时间:2010-03-18 17:45:53

标签: flex actionscript-3 actionscript flex3

我正在使用flash.display.Loader加载this example SWF作为用例来加载在我正在处理的应用程序中使用flex图表组件的SWF。

这是我用来加载swf的代码:

Main.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete(event);">
<mx:Script>
<![CDATA[

import mx.events.FlexEvent;
import myLoaderClass;

private function onCreationComplete( e:FlexEvent ):void
{
    trace("Init!");
    var l:myLoaderClass = new myLoaderClass();
    this.addChild(l);
}

]]>
</mx:Script>    
</mx:Application>

myLoaderClass:

package 
{   
    import mx.core.UIComponent;

    import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.utils.Dictionary;



    public class JittRunner extends UIComponent 
    {

        private var displayedObjects:Dictionary;

        public function JittRunner():void 
        {
            displayedObjects = new Dictionary();

            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            var mLoader:Loader = new Loader();
            var mRequest:URLRequest = new URLRequest('ChartSampler.swf');
            mLoader.load(mRequest);         
        }

    }
}

问题是,swf加载的那一刻我得到以下运行时错误:

  

错误:找不到资源包消息   在mx.resources :: ResourceBundle $ / getResourceBundle()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ framework \ src \ mx \ resources \ ResourceBundle.as:143]   at mx.utils :: Translator $ cinit()   在全球$ init()   在mx.messaging.config :: ServerConfig $ cinit()   在全球$ init()   at _app_FlexInit $ / init()   在mx.managers :: SystemManager / http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ framework \ src \ mx \ managers \ SystemManager.as:3217]   在mx.managers :: SystemManager / docFrameListener()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ framework \ src \ mx \ managers \ SystemManager.as:3069]

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

我认为您在发布的代码中没有做错任何事。我只是将它粘贴到一个新项目中(重命名为JittRunnermyLoaderClass)并且编译并运行正常(没有做任何事情但没有错误)。