Can I get some help with changing the color of an object?

I’m trying to make the following - I have 5 buttons corresponding to five sections in my Flash movie…I want to make it so, that when I click on a button it background color changes(to show that it was clicked and I’m in that section)…
The button is located inside a movieclip(not in the root timeline)…
For the purpose I converted the background of the button (which I want to change) to a movie clip, so I could use the “setRGB” command, but still I’m doing something wrong and nothing happens…
Can someone explain to me clearly the mechanism of changing the color of a movie clip?

Thanks in advance!

So you want to change the background colour of the button when you click it? What happens to the first button you clicked when you click another button?

  1. You can make a movie clip work like a button. In the movie clips timeline, label some frames “up”, “over”, “down” and “hit”.

and some on(rollOver), on(press), on(rollOut) and on(release) actions to the movieclip. Your movie clip needs and instance name (eg. buttonMC1)

each action will look like this:

on(release){
_root.buttonMC1.gotoAndStop(“hit”);
_root.gotoAndStop(“mySection1”);
}

On the “hit” frame of the movieclips timeline you will have changed its background so that when you click and release the movieclip it goes to that frame and the background colour is changed. It also goes to the frame labelled “mySection1” in the main timeline. If you want it to return to its original colour when you click another button, add a script to the second button that instructs all other buttons to go to their “up” frame. So on the movieclip called “buttonMC2” you have:

on(release){
_root.buttonMC2.gotoAndStop(“hit”)
_root.gotoAndStop("mySection2);
_root.buttonMC1.gotoAndStop(“up”);
}

So, when you click the movieclip:

  • The movieclip goes to its “hit” frame
  • The main timeline goes to the “mySection2” frame
  • buttonMC1 goes to its “up” frame.

As for setting colour with actionscript, if you are just trying to do what I explained above then what I’ve written is the simplest way. You’d do about the same amount of scripting to use the colour object, but it would go something like this:


on(release){
_root.buttonMC1.backgroundMC.(function here that changes the background colour);
}

If you want the backgrounds to be a random colour every click let me know and I will explain it in another post.

Fisrt of all! Thanks a lot! I decided to stick to the second method (to keep the buttons and modify them, instead of making a movie clip behave like a button)…But since my actionscripting abilities aren’t great at all, I want to ask some more questions! I think I’m having trouble with writing the “path” to the movie clip! I have the main timeline, then there is a movie clip in which is the button, and in the button I put the background movie clip!
So I tried with
on (Release) {
_root.movieclip.button_name.button_background_name.Color.setRGB = (0x33333FF)
}
I get no errors from Flash, but when I click on the button nothing happens…

Try this. The button is named buttonMC, the nested movieclip is named buttonMCMC:

[AS]

on(release){
buttonColor = new Color (_root.buttonMC.buttonMCMC);
buttonColor.setRGB(0x7764ff);
}

[AS]

You also had 7 characters following the 0x in your setRGB property. The above works for me.