views:

576

answers:

2

Hello everyone. I have a component which is created dynamically. I want to access the properties on it.

for example i create a vbox and i want to access the text font or gap of the component

var MyVBox: VBox = new VBox; MyPanel.addChild(MyVBox);

How should it be done?

A: 

The thing to remember when using ActionScript instead of MXML is that the style properties are not accessed as properties on the object but through the getStyle("propertyName") method. Font is a style for example.

James Keesey
i am new in ActionScript. I code delphi before and the code is very different. I started study flex 2 weeks from now. By the way how should it be done? Can u give me an example code? thank you for your quick response
Jejad
+2  A: 

All properties and methods are accessed with "." (dot) notation.

Example:

myVBox.width = 400;

Styles are set using the setStyle() method. In your case that would be

myVBox.setStyle("fontFamily", "arial");
myVBox.setStyle("verticalGap", 20);

Check the docs at http://livedocs.adobe.com/flex/3/langref/ for the available properties and styles of each component.

Christophe Herreman