flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Line" <markl...@gmail.com>
Subject RE: Image properties problem when view is not a firstView in Flex
Date Tue, 09 Jul 2013 12:01:29 GMT
Hi Philip,


I've cc the users as it may help someone else.


To fix your problem it's pretty simple. I've just added an event listener on
the complete event which the spark Image control has.


The event is dispatched once the Image control has loaded its source.


The full class is below:


<?xml version="1.0" encoding="utf-8"?>

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

            xmlns:s="library://ns.adobe.com/flex/spark" title="VIEW1"






                  import mx.events.FlexEvent;


                  protected function


                        //trace("Image Width = " +



                  private function


                        trace("Image Width = " + myImage1.bitmapData.width);






      <s:Image id="myImage1" source="images/image1.jpg"
complete="myImage1_completeHandler(event)" />




As to why you were seeing the problem in the first place. You were listening
for the creation complete function the view. The view will dispatch the
event once all of its children have been created. (By children I mean
components you have added to the view in mxml in this case)


An spark Image control was created (if you look in the debugger you can see)
but it hadn't loaded its content. This is why the bitmapData was null.


Hope that helps explain




From: Philip Medlam [mailto:philip.medlam@gmail.com] 
Sent: 09 July 2013 11:15
To: markline@gmail.com
Subject: Image properties problem when view is not a firstView in Flex


Hi Mark,


I have attached an fxp file (160k) to highlight the problem.


With the initial configuration, when I click the "View1" button, the image
in view1, does not appear to have properties in the creation complete


If I change the Main program, so the firstView is View1 (rather than Main),
then all OK?


In my actual program, I want to go to a main program and then select the
view I wish to go to.

When  I go to the view (view1 in this test example), I want to get the image
properties and scale the image appropriately.


I don't understand why the properties "exist" if I go to the view as the
firstView, but not if I call the view from another component?


TIA for your help.


I haven't sent this to the group, as I am not sure that attachments are




Philip Medlam 

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message