all groups > flash actionscript > may 2005 >
You're in the

flash actionscript

group:

How to :button change color after it has been clicked


How to :button change color after it has been clicked Alikat
5/12/2005 4:38:51 PM
flash actionscript:
Re: How to :button change color after it has been clicked sampurtill
5/12/2005 5:30:05 PM
Are you using button symbols for your buttons or movieclips? It will be much
easier if you are using a movieclip. To change the color using a movieclip,
make a symbol with a background symbol inside of it that is also a movieclip.
Now create a function to make it work when someone rolls over it and presses
it. If you just want to change the background colors, use the function below.

function newButton(buttonName:MovieClip, buttonBgName:MovieClip){
var my_color:Color = new Color(buttonBgName);
var originalColor = 0x999999;
var rollOverColor = 0xFFFFFF;
var pressedColor = ox666666;
my_color.setRGB(originalColor)
buttonName.onRollOver = function(){
my_color.setRGB(rollOverColor);
}
buttonName.onRollOut = function(){
my_color.setRGB(originalColor)
}
buttonName.onPress = function(){
my_color.setRGB(pressedColor);
originalColor = pressedColor
}
}


I havent tried this with flash, but hopefully this works. All youre going to
have to do is call the function on the button, so say the button name was
"links", and the background name was "links.bg", so this is what the function
would look like...

newButton(links, links.bg)

If this doesn't work, I'm sure there's just some little small thing wrong with
it. Sorry, I don't have flash on this computer, I'm just going from memory.
Hope this helps!!

// Sam
AddThis Social Bookmark Button