Search code examples
actionscript-3apache-flexactionscriptflash-builderflex4.5

How to change properties of elemnts\childs created with script on flash builder


Hi guys im creating/adding elemnts in my item renderer but from some reason you cant access their specific properties, you can only change the general properties. I created a LABEL component but when i do LabelName.font , nothing happens, its like flex doesnt recognize that this is a LABEL. Here is my code

                var mylabel:Label = new Label()
                mylabel.font

when i do "mylabel.someProperty" it only shows the general properties of any component, but how can i change other properties like font,color,size etc..

Thanks ahead [=


Solution

  • Fonts are defined as styles in Flex, not propeties, so you need to use the setStyle method to update it. (Not my favorite part about Flex.) For example:

    myLabel.setStyle('fontFamily', newFont)