0

Say I have this in mxml (sparkskin) :

<s:SolidColor id="fillColor" 
                      color="0xff0000"
                      color.selectedOver="0xf74b47"
                      color.selectedUp="0xf74b47"/>

To change color property in AS3 the syntax is :

fillcolor.color = 0x00ff00;

Now I want to change color.selectedOver in AS3.

Is there a way ?

ie fillcolor['selectedOver'].color = 0x00ff00; ...
Pinfred
  • 3
  • 3

2 Answers2

0

You can't access it directly, color is just an integer property in AS. Not sure if there is a better way but you could bind the color value to a variable and change that variable at runtime:

// place this in your Script section 
[Bindable]
private var selectedOverColor:int = 0xf74b47;

// bind the color value to your variable
<s:SolidColor id="fillColor" 
                  color="0xff0000"
                  color.selectedOver="{selectedOverColor}"
                  color.selectedUp="0xf74b47"/>

// change this variable to the new color somewhere at runtime:
selectedOverColor = 0x000000;
Philarmon
  • 1,796
  • 1
  • 10
  • 14
0

Thanks, I agree. The only solution seems to override updateDisplayList and use something like :

switch (currentState){
    case 'selectedOver':
       fillColor.color = 0xff0000;
       break;
    case 'selectedUp'
       fillColor.color = 0xffff00;
       break;

         ...
}
Fred
  • 399
  • 3
  • 12