Skip navigation
Home/Support/

Forums

188 Views 2 Replies Latest reply: Jul 19, 2010 1:48 PM by shawnyale RSS
shawnyale Calculating status... 87 posts since
Aug 6, 2007
Currently Being Moderated

Jul 16, 2010 8:47 AM

Is there a way to get a resized element height by ILayoutElement??

Hi all,

I am currently working on a means of layout out dynamic text and want my layout to check the RichText component to determine if it has enough space horizontally to fit in the available real estate.  For example, if the available browser width is 300px, and the RichText is 200px, everything is fine and the component can be placed without modification.

 

However, if the browser is 300px and the component is 400px, I want to resize the component to fit into the available space and trigger the RichText to present its content in a multi-line format.  I'm really close to a solution, but Ive been unable to find out if there is any means to get the height that the component will be once the width resize is complete.

 

The crux of this approach relies upon using ILayoutElement within the layout and resizing as follows:

 

element.setLayoutBoundsSize(target.width-HorizontalGap, NaN)

 

Now I know that setting the height to NaN causes this method to set the elements height to its preferred height.  I've checked the other available methods such as element.getLayoutBoundsHeight(), element.getPreferredBoundsHeight(), element.getMaxboundsHeight() but these all appear to return the height as if the resize for multi-line didn't exist.

 

My question is that I would like to find a way to figure out what the new height is GOING to be once the width resize occurs.

 

Any thoughts?  Thanks in advance!

 

PS. While stepping through, I noticed there is a protected $height that appears to have the correct height, but there doesn't seem to be a way to access it.  Do I need to subclass ILayoutElement to make this value available or is there something Im not seeing.

 

Cheers!

  • Shongrunden Adobe Employee 1,356 posts since
    Jun 16, 2009

    You can get at the $height property in the mx_internal namespace, for example:

     

    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   creationComplete="init()">
       
        <fx:Script>
            <![CDATA[
                import mx.core.mx_internal;
                use namespace mx_internal;
               
                private function init():void {
                    trace(btn.mx_internal::$height);
                }
            ]]>
        </fx:Script>
       
        <s:Button id="btn" />
       
    </s:Application>

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points