Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Flex component width to 100% at runtime?

If I am creating say a input field through MXML, I can set the width to 100%. But I cannot seem to do this at runtime through ActionScript.

This works:

<mx:TextInput ... width="100%" />

This wont compile, says width is a number, not a string:

var textinp:TextInput = new TextInput();
someContainer.addChild(textinp);
textinp.width = "100%"

How can I set 100% as the size on a component created at runtime via ActionScript?

like image 570
davr Avatar asked Jun 25 '09 20:06

davr


1 Answers

You just need to use the percentWidth attribute, instead of the width attribute.

So, the third line in your code would be :

textinp.percentWidth = 100;

This tripped me up for awhile, too.

like image 82
Ross Henderson Avatar answered Sep 28 '22 06:09

Ross Henderson