Adobe Dreamweaver Forums



Last 10 THreads :         Re: 2.1 GB TIF size limit (Last Post : Buko - Replies : 0 - Views : 1 )           »          Re: Colour differences on the web (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: sRGB vs. Adobe (1998) RGB (Last Post : pfigen@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: SFW and date created (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 0 - Views : 1 )           »          help me with adjustments layers in CS4 (Last Post : Ramón_G_Castañeda@adobeforums.com - Replies : 1 - Views : 2 )           »          Snippet Pod Problems (Last Post : Pat@ffic - Replies : 4 - Views : 5 )           »          bad luck (Last Post : newwaveboats - Replies : 0 - Views : 1 )           »          Cannot setup audio with Captivate 2 (Last Post : c..k - Replies : 0 - Views : 1 )           »          Re: Urgent: Can Only Record in Demonstration Mode (Last Post : halyna - Replies : 0 - Views : 1 )           »          Change custom Vector class to new Vector class in player10 (Last Post : VarioPegged - Replies : 1 - Views : 2 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-04-2008, 09:02 AM
Handycam
 
Posts: n/a
Diggs:
Default Problem getting image size

I am loading an image into an image component dynamically on component
creation. The images are all different sizes for each instantiation of this
component. I am trying to set the size of the component to match the size of
the image. I have tried a couple of ways, and am now doing it with the
attached code.

However, the object is always larger than the image, which is causing me
problems. I have tried removing the minHeight/minWidth, but then nothing shows
at all. Any ideas appreciated, this is the last bug I have to fix...



<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"
minWidth="200" minHeight="200" creationPolicy="all">
<mx:Script>
<![CDATA[
...

private function init():void {
itemImage.source = filePath;
itemImage.addEventListener(FlexEvent.DATA_CHANGE, setSize);
}

private function setSize():void {
this.width = itemImage.measuredWidth;
this.height = itemImage.measuredHeight;
}

...
]]>
</mx:Script>

<mx:Image id="itemImage" />

</mx:Canvas>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-04-2008, 09:02 AM
_funkyboy
 
Posts: n/a
Diggs:
Default Re: Problem getting image size

Is the image loaded when you try to access itemImage.measuredWidth or height?
Reply With Quote
  #3 (permalink)  
Old 11-04-2008, 09:02 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Problem getting image size


"Handycam" <webforumsuser@macromedia.com> wrote in message
news:ge7f06$mvi$1@forums.macromedia.com...
>I am loading an image into an image component dynamically on component
> creation. The images are all different sizes for each instantiation of
> this
> component. I am trying to set the size of the component to match the size
> of
> the image. I have tried a couple of ways, and am now doing it with the
> attached code.
>
> However, the object is always larger than the image, which is causing me
> problems. I have tried removing the minHeight/minWidth, but then nothing
> shows
> at all. Any ideas appreciated, this is the last bug I have to fix...


This doesn't completely address your problem, but might help with the layout
problems you're having:

http://flexdiary.blogspot.com/2007/1...roperties.html

HTH;

Amy


Reply With Quote


  #4 (permalink)  
Old 11-04-2008, 09:02 AM
mhartnett
 
Posts: n/a
Diggs:
Default Re: Problem getting image size

I forgot to mention that I don't believe that the measuredWidth/Height or the
width/height is available at the complete event time.

You would either use contentWidth / contentHeight or use
var r : Rectangle = imageItem.getRect(imageITem) to get the dimensions.

Reply With Quote
  #5 (permalink)  
Old 11-04-2008, 09:02 AM
Handycam
 
Posts: n/a
Diggs:
Default Re: Problem getting image size

Thanks mHartnett, that was it!

In the init function, changed the event listener to:
itemImage.addEventListener(Event.COMPLETE, setSize);

And then the handler:

private function setSize(e:Event):void {
this.width = itemImage.contentWidth;
this.height = itemImage.contentHeight;
}

Made my day!

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 11:32 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk