PDA

View Full Version : setting width to 100% for a dynamically created element


tata668
08-13-2007, 04:18 PM
Hi,

I'm new to Flex. Here's my problem:

I dynamically create a VBox and I want to give it "100%" for its width.

I tried:


var oneVBox:VBox = new VBox();
oneVBox.width = "100%";


But this gives me the error: "Implicit coercion of a value of type String to an unrelated type Number".

I tried

var oneVBox:VBox = new VBox();
oneVBox.setStyle("width", "100%");

But it doesn't seem to work.

How can I do it?

Thank you!

JL

Deniz
08-13-2007, 05:03 PM
oneVBox.percentWidth = 100;

(see the VBox documentation: percentWidth : Number
Number that specifies the width of a component as a percentage of its parent's size.)

tata668
08-13-2007, 05:14 PM
Thanks!