views:

618

answers:

2

Flex Builder defaults some components to "fit to content" if you don't specify a set width or height. I'm trying to fill a mx:Tile component with Actionscript, but the layout has some strange spacing when I don't specify the width of a component I add to it. Is there a way to set the components to "fit to content" using Actionscript?

A: 

Do you still need the tiles to align in columns/rows, or do you want them all to be fit-to-content? If you want the former, good luck, and I hope someone else can answer for my benefit. If you want the latter, you could use FlowContainer (which I got from Appdivision).

Jacob
A: 
// AS3 way
var c:UIComponent = <your component that should fit into parent's content>;
c.percentWidth = 100;
c.percentHeight = 100;

// MXML way
<mx:Canvas>
   <mx:Button id="c" width="100%" height="100%"/>
</mx:Canvas>
oshyshko
I'm looking to fit the parent to the children, the mx:Tile component has some odd behavior if I don't specify width such that the components aren't spaced evenly. I thought finding a way to specify "Fit to content" for the parent component might fix it, but this may be another problem entirely.
timbonicus
ts hard to understand what you mean. Could you edit your question and post a small piece of code so I can copy-paste it and see the problem?
oshyshko