Image height and width binding

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Image height and width binding

Justin Mclean
Hi,

In trying g to solve the image height and width issues I was having the other day I also tried this which also didn’t work as expected.

It looks to me that the heightChange and widthChanged events are not dispatched either after the image loads or when the image is replaced with another one.

Is this a bug?

<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:js="library://ns.apache.org/royale/basic">

   <fx:Script><![CDATA[      
       public function changeImage():void {
           image.src = "http://apache.org/img/flex.jpg";
       }
       ]]></fx:Script>

    <js:beads>
         <js:ApplicationDataBinding />
     </js:beads>

   <js:valuesImpl>
       <js:SimpleCSSValuesImpl />
   </js:valuesImpl>

   <js:initialView>
       <js:View width="100%" height="100%">
           <js:beads>
               <js:VerticalLayout />
           </js:beads>
           <js:style>
               <js:SimpleCSSStyles margin="50" />
           </js:style>
           <js:Label text="Here's the ASF logo" />
           <js:Container id="holder" width="520" height="300">
               <js:style>
                   <js:SimpleCSSStyles backgroundColor="#333333" />
               </js:style>
               <js:Image id="image" src="http://apache.org/img/asf_logo.png" x="{(holder.width - image.width)/2}" y="{(holder.height - image.height)/2}" />
           </js:Container>
           <js:TextButton text="Change Image" click="changeImage()" />
       </js:View>
   </js:initialView>

</js:Application>

Thanks,
Justin