Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button for changing the colour of a layer

Status
Not open for further replies.

hugz

Programmer
Jun 3, 2003
8
0
0
GB
Hi,

I am trying to create a button that will change the colour (or hue/saturation) of a particular layer. Its for a colour scheme program that will allow users to select different parts of a room and colour them from a set of available shades.

Any help would be most appreciated.

Hugo
 
You can't change the color of a layer as such, you should look into the Color(Object) in the AS dictionary.
 
How about having many layers for the same item (just coloured differently) and hiding/showing the ones you want?
 
Convert your layer to a movieclip, let's say 'layerClip' for this example. Then you can control its colour with this code:

Code:
layerColour=new Color(layerClip);
);//changes the layer to solid red
//0x0000ff would change it to solid blue
layerColour.setRGB(0xff0000

...if you want to tint the clip rather than fill it with a solid colour then you'll have to add another object to the code to take care of the transform:

Code:
layerColour = new Color(layerClip);
//these values are transforms and offsets which affect the 
//colour in the same way as the controls in the 'advanced' colour panel
layerTransform = {ra:50, ga:30, ba:45, rb:100, gb:32, rb:-67};
layerColour.setTransform(layerTransform);
 
Thanks wangbar,

Did you mean 'bb' instead of 'rb' in the line:

layerTransform = {ra:50, ga:30, ba:45, rb:100, gb:32, rb:-67};

Hugz
 
Where abouts do i put this code? and how do i make the action take place?

Do i need to put it in a button's 'on press/release' segement?

i have a book but it has given me the same code as you have and i still dont understand. i realise i must be missing something fairly obvious and it is really fustrating.

thanks for all your help

hugo
 
The best way to do something like this is to put the main part of the code inside a function on the first frame of your movie - I usually create a new layer in the timeline just for all of the code I'm going to use. Then you can call this function from your button.

Give me your email address and I'll send you a simple example.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top