PDA

View Full Version : Changing the style of a child component...


Tony_Almeida
05-21-2007, 02:55 PM
Hi Everyone,

I'm in a bit of a bind - can't seem to get the following right...

What would the syntax be to change the style of a child added to a canvas? Basically I have an mxml component which contains a canvas. That canvas is populated using the addchild method with another mxml component that contains an HBox and a single label. What happens is I add the HBox mxml component to the canvas multiple times - my goal is to change the style of the label within the added mxml component to something else once it has been added to the canvas. I'm not sure what the syntax would be in order to achieve this - I'm thinking along the lines of 'nameOfCanvas.getChildAt(n). ...'.

Any idea how I would be able to achieve this?

Thanks for your time,

- Tony

dr_zeus
05-21-2007, 06:40 PM
Your idea could work:

(nameOfCanvas.getChildAt(0) as UIComponent).setStyle(styleName, styleValue);

Tony_Almeida
06-12-2007, 11:48 AM
Thank you for your response :), apologies for mine being so late.

I gave that a shot and unfortunately it didn't change the style (I need to play with it some more), however I found a workaround... my objective at the time was to make a child look greyed out, so I used the alpha effect to get this done using the following code to access a given child:

fadeOut.target = nameOfCanvas.getChildAt(_i - 1);

I'll play around with the syntax you provided some more, changing the style of children added to a container is convenient.

Thanks again,

- Tony