wzazza
wzazza

Reputation: 853

Flash Change button color with ActionScript2

I have Flash file with buttons in it, and the color of those buttons changes dynamically when flash loads, the color code is taken from XML file and it changes the color of button with

color.setRGB(color_code_from_xml);

And all here works ok. The problem is with hover color on those buttons, it should be always white but I just cant make it happen, after setRGB() loaded color all states of button (over, down, hit) is in that same color.

How to make the buttons keep the hover color white?

Hope this is understandable, I`m totally new to Flash. Thank you very much.

Upvotes: 0

Views: 3709

Answers (1)

Andrius Baruckis
Andrius Baruckis

Reputation: 669

var color_code_from_xml:Number = 0xFF0000; // here you will pass your value from XML

var my_color:Color = new Color(my_button); 
my_color.setRGB(color_code_from_xml); // my_button turns to color (red) from XML

my_button.onRollOver = function() { // on mouse roll over
    my_color.setRGB(0xFFFFFF); // my_button turns white
}

my_button.onRollOut = function() { // on mouse roll out
    my_color.setRGB(color_code_from_xml);  // my_button restores to color (red) from XML
}

my_button.onPress = function() { // on mouse press
    my_color.setRGB(0x0066FF); // my_button turns blue
}

Upvotes: 1

Related Questions