I have three images and I want change the images size based on the scene size (default size is 1024x768). After each image has completely loaded I call bindableUtils.setter to set width/height when scene size changes but I don't know how to make a pointer or something like that. I'm using a public var img, but it only works with the last complete image.
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.binding.utils.BindingUtils;
public var img:Image;
private function setterWidth(newWidth:Number):void
{
img.width = img.content.width * newWidth / 1024;
}
private function setterHeight(newHeight:Number):void
{
img.height = img.content.height * newHeight / 768;
}
protected function image_completeHandler(event:Event):void
{
img = event.target as Image;
BindingUtils.bindSetter(setterWidth, this, "width");
BindingUtils.bindSetter(setterHeight, this, "height");
}
]]>
</fx:Script>
<mx:Image id="img1" source="img1.jpg" complete="image_completeHandler(event)" />
<mx:Image id="img2" source="img2.jpg" complete="image_completeHandler(event)" y="60"/>
<mx:Image id="img3" source="img3.jpg" complete="image_completeHandler(event)" y="120"/>
</s:Application>
I don't use a for each image extra bindSetter function.
Maybe my idea on how I can change the size of image based on the size of the scene is wrong. How would you do it?