Two questions:

Is it acceptable for your images to be loaded at runtime instead of 
being embedded?
Are your images in JPEG and/or SWF format?

If the answers are both "Yes", you can use the following approach.  
If not, hopefully Rob will have some suggestions.  (I've already 
begun to incorporate his asset class technique as a best practice.  
Thanks Rob!)

    <mx:Model id="myModel" source="myFile.xml"/>
    <mx:Image source="{myModel.path.to.imageUrl}" />

Your xml file would contain nodes that have the relative or absolute 
paths (as plain ol' strings) to your images.  The image files need 
to be hosted on a server, not just accessible by file path.  This 
will load the images over HTTP(S) at runtime, and you could even 
bind the Image tag's source property to a variable that dynamically 
changes the loaded image from one URL to another.

Doug


--- In [email protected], "kushubhai" <[EMAIL PROTECTED]> wrote:
>
> Hi Rob and Doug,
> 
> Thanks for your help.
> 
> Basically, I have the different image file paths corresponding to 
the
> image name in an xml file.Now I need to generate a swf file with 
all
> the images specified in the xml embedded in it.
> 
> Can I somehow create the appnameAssets.as class from the xml file?
If
> possible, Rob's strategy will do wonders.
> 
> Can you please suggest any alternative strategy for it.
> 
> Thanks once more
> Kushubhai
> 
> 
> --- In [email protected], "Rob Rusher" <robrusher@> wrote:
> >
> > Kushubhai,
> > 
> > Doug is correct. @Embed is a compile-time directive. Therefore, 
in
> order to
> > reference the image dynamically, you will have to embed the 
image and
> > associate it with a variable.
> > 
> > Typically, I will create a class (appnameAssets.as) that contains
> all of the
> > embedded assets for my application. I then instantiate that 
class on an
> > 'assets' property of my ModelLocator. Then I can reference the 
embedded
> > image dynamically as ... source="{ 
ModelLocator.assets.myImage }" ...
> > 
> > HTH
> > 
> > Rob Rusher
> >  
> > RIA Consultant
> > Macromedia Certified Flex Instructor
> > e:robrusher@ c:303.885.7044 im:robrusher
> > blog:http://www.robrusher.com
> > 
> > -----Original Message-----
> > From: [email protected] 
[mailto:[EMAIL PROTECTED] On
> > Behalf Of Doug Lowder
> > Sent: Friday, March 17, 2006 12:52 PM
> > To: [email protected]
> > Subject: [flexcoders] Re: Passing actionscript variable for image
> path into
> > @Embed()
> > 
> > You can do something like this to bind an Image tag to a 
variable that 
> > refers to an embedded file.
> > 
> > In script:
> > [Embed("path/to/some/image.png")]
> > var myImage: String;
> > 
> > And in mxml:
> > <mx:Image source="{myImage}" />
> > 
> > 
> > Doug
> > 
> > --- In [email protected], "kushubhai" <kushubhai@> 
wrote:
> > >
> > > Hi,
> > > 
> > > I am trying to pass a actionscript variable to the @Embed(..)
syntax
> > > inside a <mx:Image [EMAIL PROTECTED](...) /> tag , but am unable 
to get
> > > the actual path of the image from the variable.Instead the 
variable 
> > is
> > > picked up as the literal image path..and so the image is not 
> > displayed.
> > > 
> > > Need help on this..
> > > 
> > > Thanks
> > >
> > 
> > 
> > 
> > 
> > 
> > 
> > --
> > Flexcoders Mailing List
> > FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> > Yahoo! Groups Links
> >
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to