Enter your email address:

    Delivered by FeedBurner

Wednesday, January 07, 2009

Actionscript: Dynamically Change Object Color Through Bindings

Sometimes you would want to change the color, disabled color, or any other colors of an object, like a text box, for some reasons. And sometimes, you would want to make the code inline on the object's properties, which is I think is a good practice.

To dynamically change the color of an object straight from the properties, bind the inline "if" condition on the properties of the object.


Example, you would want to make the disabled color of an object set to #000000 when the check box is selected (checked), and set it to #B5B5B5 when not selected.

disabledColor="{(checkbox1.selected == true)?uint('0x000000'):uint('0xB5B5B5')}"


So, you would have a code that looks like:

<mx:TextInput disabledColor="{(checkbox1.selected == true)?uint('0x000000'):uint('0xB5B5B5')}">


The inline "if" condition syntax...
{(condition)?condition is true:condition is false}


0 comments:

Post a Comment

About Me

My photo
I provide health supplements, adult wellness products, glutathione, and other merchandise. Please visit my online shop at: http://luckycowshop.blogspot.com/