简体   繁体   中英

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.

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM