find inner width/height of BorderContainer component - apache-flex

I have a BorderContainer having top:30, bottom:5, left:2, right:2 so that it resizes with the applicaiton.
I have a custom component within it that needs to resize when the container resizes.
The problem is that getting the width and height of the container directly is not working. It seems to have a minimum width and height of 500.
Instead I have to get the width/height of its parent, which is in fact a BorderContainerSkin, then subtract the borderWeight * 2.
Is there a function that returns this?

So are you trying to manage component size inside component? It's not the Flex way. The component's parent should set its children sizes during layout. Try to set percentHeight and percentWidth (or width/height="100%") in your component.

Related

Actionscript -> Any article about the difference between getLayoutBoundsHeight and getPreferedBoundsHeight

Can't find any article about the difference . Does somebody know one?
getLayoutBoundsHeight will do this:
Returns the element's layout height. This is the size that the element
uses to draw on screen.
getPreferredBoundsHeight will do this:
Returns the element's preferred height.
In the context of Flex, the size of a component is always determined by its' parent. A component cannot size itself. A measure() method must be implemented--it is part of the component lifeCycle--and it will set the measuredHeight (and measuredWidth) of a component. So, the layoutBoundsHeight is the actual height. The preferredBoundsHeight is the desired height. In Flex, especially when dealing with layout containers or percentage layouts, Flex may make decisions to size a component differently than the measured size.

What is the actual height of a container without scrollbars?

Probably a silly question but, what is the actual height of a container in Flex without scrollbars? Height and measuredheight seem to tell me what the visual height of a container is, but I want to know that number plus any height that is being 'hidden" below a scrollbar.
Thanks.
You can get the height with this:
box.mx_internal::getScrollableRect().height;
HBox and VBox always resizes to it's children if I remember correctly. So the height/width property will always be that of the content within it.
As for SWFLoader, it acts more like a Canvas. If you want to get the width/height of the content, just use the contentHeight/contentWidth property. The height/width of SWFLoader should be the size of the "Canvas" and not it's children.
I believe for the scrollbar itself, only certain components do that (like canvas), and I believe the algorithm to add the scrollbar is along the lines of if contentHeight > height => add vertical scrollbar. The HBox and VBox shouldn't ever get a scrollbar, unless you specify the 'clipContent' property to true. I personally would steer away from using that and instead just wrap it in a Canvas.

Flex desktop application: How to position elements relative to the window size

I am creating a desktop application with Flex for the first time. I am having problems with the position and size of the elements in the screen. For instance
Elements with 100% width do not resize when the window is resized or maximized
Elements positioned relative to the bottom of the window do not move when resizing or maximizing the window
How do I solve these problems? Are there any good practices that I should follow when using Flex to develop a desktop app?
from http://nondocs.blogspot.com/2007/04/flexfaqpercentwidthpercentheight.html :
If you set percentWidth and
percentHeight of a UIComponent whose's
parent is not a Container these
properties may not effect the size of
the UIComponent. This is because
UIComponents do not actually check
percentWidth and percentHeight.
Instead the UIComponent's parent
Container checks it's childrens'
percentWidth and percentHeight and
resizes the children accordingly.
Ok, I found what I needed in Adobe's official docs... I should have looked there in the first place:
Laying Out Components
One of my problems was that I was setting the width and height of the Application, and the Flash Player does not change that parameters even if you resize its window.

Flex: change containers size to wrap the content

I'm using TitleWindow with PopupManager.
I programmatically add the children to my TitleWindow and I would like the TitleWindow changing its size in order to avoid scroll-bars.
Is there any property to mek the windows wrapping the content in Flex ?
thanks
The way I do this is to give it a minHeight and minWidth, but no height or width properties. That way it shrinks to fit the content.
Be careful, though. If you have too much content it can go off the screen, so set a maxHeight and maxWidth. Or else resize title window based on screen loc and dimensions. Then you still have to handle scrollbars, but it happens much less often.

Set height of Flex Accordion to height of tallest child

By default the height of an Flex Accordion container is the height of the initially selected child. I'd like to be able to set the height to the tallest child so that no resizing or scrolling is necessary when other children are selected.
I do not want to use the resizeToContent property. I want the size of the container to stay constant no matter what child is selected.
My current thought is to extend the accordion class setting the creation policy to "all" and then override the measure function to loop through all the children and find the tallest one and use that for the height. This seems a little kludgy though, so I'd like to know if there is a better approach.
Ultimately my question is: is there a way to set the size of an accordion container such that the container never resizes and scoll bars are never necessary to display any of the children?
IMO your idea is probably the best way to go, one problem with it though, you're still going to have a scroll bar since it will set the height to the child and not take into account the chrome of the accordion. So you will need to add additional height for each header of the accordion.
Simple to figure out the header height and multiply it by the number of children, but still something you should keep in mind.

Resources