开发者

ActionScript3: Load XML located inside .swc

I have written a Flex Library project - a .swc file - which is supposed to read default configuration from a XML file inside .swc. This .swc file would be used by other modules to perform some operation. I am unable to make the URLLoader to load the XML inside the .swc file.

When i run this as a normal Flex project, things work fine without any issue. With swc, it looks bin-debug folder for the XML and not inside .swc. I want the URLLoader开发者_JAVA技巧 to look inside .swc for the config file. How do i achieve this?

myLoader.load(new URLRequest("config.xml"));

For the above code i get the following error:

Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file:///C:/nav/workspace/Test/bin-debug/config.xml

How do i make the URLLoader to look into .swc file?


To load the xml from inside the SWC, you will have to embed the xml file into the SWC using something like

    [Embed('assets/myConfig.xml')]
    public static const myXmlConfig:Class;

From there you can cast the myXmlConfig object to Xml and parse it normally.

Alternatively, if you want to load the XML from outside the SWC, check out the answer to this question

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜