views:

76

answers:

1

hi, I want to display a png with flex's builtin image component.

There's a specific x, y that I want this image to be displayed.

How do I do it? I am pretty new to flex.

+1  A: 

This is easy. See the online Adobe documentation on positioning.

<mx:Image id="img0" 
            source="@Embed('logo.jpg')" 
            x="40" y="40"/>

Of course you can choose not to Embed the image and load it directly from a different URL. I strongly recommend going through the API documentation.

And always refer to the documentation: ImageControl

Edit: Using the Image control in AS3 code

import mx.controls.Image; 

public function SetImageProperties(url:string, x:int, y:int) : void {
   var imageLoader:Loader = new Loader();
   var image:URLRequest = new URLRequest(url);
   imageLoader.load(image);
   addChild (imageLoader);
   imageLoader.x = x;
   imageLoader.y = y;

}

Use a loop/Repeater component for multiple images.

dirkgently
is there a way to do it with code and not xml? the x and y position of the image changes.And I also want to have multiple of the same images.
SuperString
@SuperString: See my edit.
dirkgently
I tried using your code but I don't really understand how to use it. I have some image in my assets folder called image.png.Do I have to embed it before I call your function?I am not sure what this URL is either. is it "assets/image.png"?
SuperString
Yes, you will need to embed them. Did you go through the documentation? See http://www.adobe.com/devnet/flex/quickstart/embedding_assets/
dirkgently
yea. This is my code:[Embed(source="assets/image.png")][Bindable]public var img:Class; Now lets say I want to put it in location 10, 10.How do I call your method to do what I want?
SuperString