The following example shows how you can detect when the source property has changed on a Flex Image control using the sourceChanged event.It shows a alertbox when the source is changed.
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml“
layout=”vertical”
verticalAlign=”middle”
backgroundColor=”white”>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void {
img.addEventListener("sourceChanged", image_sourceChanged);
}
private function image_sourceChanged(evt:Event):void {
Alert.show(evt.toString(), evt.type);
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock=”true”>
<mx:Button label=”Flash”
click=”img.source = ‘pic1.jpg’;” />
<mx:Button label=”Flash Player”
click=”img.source = ‘pic2.jpg’;” />
</mx:ApplicationControlBar>
<mx:Image id=”img”
source=”pic3.jpg”
initialize=”init();”
width=”100″
height=”100″ />
</mx:Application>