Search code examples
actionscript-3apache-flexmxml

Flex: Properties of an item are not accessible in action script


This question talks about verticalAlign property but the answer might be relevant for other style properties as well.

I have a grid object in my mxml file:

<mx:Grid width = "100%"
         height = "100%"
         id = "myGrid">
    <mx:GridRow width = "100%">
        <mx:GridItem verticalAlign = "middle">
          // Some design code
        </mx:GridItem>
    </mx:GridRow>
</mx:Grid>

I'm trying to add rows programmatically using action script:

var configurationItem:GridItem = new GridItem();

But there is no verticalAlign property for the grid item instance. Is there a way to set this property in action script?


Solution

  • The verticalAlign is a style and not a property.

    To achive that from ActionScript use:

    var configurationItem:GridItem = new GridItem();
    configurationItem.setStyle("verticalAlign", "middle");
    

    Hope that helps.