views:

186

answers:

1

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 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?

+1  A: 

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

Jason W
Jason,it worked!! Thanks a lot. I was pulling my hair on this for past few hours. You saved my day :)Additional info: i casted myXmlConfig.data to XML as follows: configXML = myXmlConfig.data as XML;
navr
Additional Info: No URLLoader used to get it working.
navr
Glad to hear you got things working :)
Jason W