flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Velasco <carlos.velasco.bla...@gmail.com>
Subject Re: Image properties problem when view is not a firstView in Flex
Date Tue, 09 Jul 2013 12:42:01 GMT
If you're interested take a try on Uriana (
https://www.assembla.com/spaces/uriana/wiki) as it makes unnecessary the
use of creationComplete and this problem might not happen to you.

Cheers,
Carlos.


2013/7/9 Mark Line <markline@gmail.com>

> 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"
>
>             creationComplete="view1_creationCompleteHandler(event)">
>
>
>
>       <fx:Script>
>
>             <![CDATA[
>
>
>
>                   import mx.events.FlexEvent;
>
>
>
>                   protected function
> view1_creationCompleteHandler(event:FlexEvent):void
>
>                   {
>
>                         //trace("Image Width = " +
> myImage1.bitmapData.width);
>
>                   }
>
>
>
>                   private function
> myImage1_completeHandler(event:Event):void
>
>                   {
>
>                         trace("Image Width = " +
> myImage1.bitmapData.width);
>
>                   }
>
>
>
>             ]]>
>
>       </fx:Script>
>
>
>
>       <s:Image id="myImage1" source="images/image1.jpg"
> complete="myImage1_completeHandler(event)" />
>
>
>
> </s:View>
>
>
>
> 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
>
>
>
> Mark
>
>
>
> 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
> handler?
>
>
>
> 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
> allowed.
>
>
>
> Phil.
>
>
>
>
>
>
> --
> Philip Medlam
>
>

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