You might be able to embed it.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of edlueze Sent: Sunday, July 20, 2008 11:22 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Bake XML File into ActionScript Hi Randy - thanks for the feedback! I was hoping to find a way to preserve the XML file without contaminating it with the "private var novel:XML = " bit. That way I can create the XML file using my favorite XML generator (and use a validating XSD schema to make sure everything is correct). When the XML file looks good I can simply drop it into my Flex project - overriding the previous XML file - and everything should just compile. That approach would work if I was working in MXML using the <mx:XML id="MyBooks" source="books.xml"/> tag. I was hoping there was an equivalent way to do it when working purely with ActionScript .as files. Any ideas? --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Randy Martin" <[EMAIL PROTECTED]> wrote: > > You can include an ActionScript file in it's own script block. Then in the > .as file, you could just have the XML defined and nothing else. > > // put this in books.as -- or whatever filename you choose > private var novel:XML = <BOOK><TITLE>My Book</TITLE></BOOK>; > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="absolute"> > <mx:Script source="books.as"/> > > ... rest of your code > > </mx:Application> > > HTH, > ~randy > > > _____ > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of edlueze > Sent: Sunday, July 20, 2008 11:02 AM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Bake XML File into ActionScript > > > > What's the best way to compile an XML file directly into ActionScript? > > You can assign an XML literal to a variable as such: > > var novel:XML = <BOOK><TITLE>-My Book</TITLE>-</BOOK> > > But it would be much better to have the XML in an externally managed > file. I'd much prefer to do something like: > > var novel:XML = {include "Books.xml";-}; > > But this doesn't seem to be allowed. > > I could load the XML file at runtime but then I'd have to deal with > the asynchronous nature of the loading and I'd have to handle any > runtime errors if there was a problem - yuck! > > If I was working in MXML I'd be able to do something very elegant such > as using the compile-time tag <mx:XML id="MyBooks" source="books.-xml"/> > > So how do I include XML into ActionScript in a way that is as elegant > as it is for MXML? > > > > > > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.523 / Virus Database: 270.5.2/1562 - Release Date: 7/19/2008 > 2:01 PM >