Hi,

Here's a way that you can embed an external xml file into your app:

[Embed('/data/myStubData.xml')]
private var myStubDataXML : Class;

private function onInitialize() : void {
     var myXML : XML = new XML( myStubDataXML.data );
}

-TH

--- In flexcoders@yahoogroups.com, "edlueze" <[EMAIL PROTECTED]> wrote:
>
> Yeah - that's what I'm currently doing. But that's a runtime solution
> - I was hoping for a compile-time solution.
>
> Thanks anyway!!
>
> --- In flexcoders@yahoogroups.com, "Randy Martin" randy@ wrote:
> >
> > I'd just read the XML file in using HttpService.
> >
> > ~randy
> >
> >
> > _____
> >
> > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
On
> > Behalf Of edlueze
> > Sent: Sunday, July 20, 2008 1:22 PM
> > 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 HYPERLINK
> > "mailto:flexcoders%40yahoogroups.com"flexcoders@, "Randy
> > Martin" <randy@> 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="HYPERLINK
> > "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: HYPERLINK
> > "mailto:flexcoders%40yahoogroups.com"flexcoders@
> > [mailto:HYPERLINK
> > "mailto:flexcoders%40yahoogroups.com"[EMAIL PROTECTED] On
> > > Behalf Of edlueze
> > > Sent: Sunday, July 20, 2008 11:02 AM
> > > To: HYPERLINK
> > "mailto:flexcoders%40yahoogroups.com"flexcoders@
> > > 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
> > >
> >
> >
> >
> >
> >
> >
> > 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
> >
>


Reply via email to