I'm not sure how much you know about Flex or Actionscript, so i decided to just give some example code:

<!--THIS IS THE IMAGE PORTION-->
<mx:Image id="myImage" source="pic.jpg"/>

<!--AND THIS IS THE ACTIONSCRIPT EMBEDED IN THE MXML-->
<mx:Script>
        <![CDATA[
                private var desiredWidth:int = 300
                private function changeWidth():void
                {
                        myImage.width = desiredWidth
                }
        ]]>
</mx:Script>


In the first portion the image is defined in the mxml, note I defined and id property as well as source. I then use the id again in the actionscript. I used it in a function so a button could trigger that function and change the width of the image to 'desiredWidth' variable at runtime.

I hope this helps
On Jul 1, 2008, at 10:13 AM, Alex Harui wrote:


People generally use mx:Image to load jpgs. Once loaded, and assuming you have domain permissions, you can manipulate the bitmap by accessing the mx:Image’s content property from AS3



From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of pankajtandon2003
Sent: Tuesday, July 01, 2008 5:47 AM
To: [email protected]
Subject: [flexcoders] How to load an image using mx:Loader



Hello folks,
I'm a newbie in flex-world!
I need to load a Bitmap (.jpg) file using Flex3.
Now I've read a bunch of code that describes how to do this using
ActionScript 3. But I'm not very sure how Flex 3 and AS3 interact.
I've got the Flex 3 Builder Eclipse Plugin and I was hoping I could
find an example of loading an image using the <mx:Loader> tag. But
strangely I do not see many posts on this forum for this. Could it be
that this is the "wrong" way to load an image using Flex?

So, specifically, can someone:
1. Provide me with an example of using <mx:Loader> to load a .jpg file.
2. Show me a simple example of how Flex3 tags and AS3 interact. For
example, if I wanted to build all UI components using Flex, but do all
Image manipulation using AS3.

Thanks in advance!

Pankaj





Reply via email to