Flash tutorials
Home 3D (2) Actionscripting (66) Animation (108) Audio (4) Drawing (7) Full flash sites (4) Getting Started (15) Navigation (25) Special Effects (61) Text Effects (38)

Changing object color on click

16.8.2007, 2:49    Total views: 59401

In this step by step tutorial, you will see how to change a object color using the action script code and color buttons. For this example, as object, I'll use toyota rim. You can apply this action script code on any object, and on that way, change its color using the buttons.






Click on any buttons below the picture to change the rim color!




Step 1

Open a new flash document.

Step 2

Draw, or Import any object. After that, select it and press F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.



Step 3

While the object is still selected, go to the Properties Panel (Ctrl+F3) below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip as whatever you like. For this example, I will call my movie clip rim_mc. See the picture below.



Step 4

Create a new layer above the objects layer and name it buttons.

Step 5

After that, create a four buttons (red,blue,brown and yellow). See the picture below.



Step 6

Take the selection Tool (V) and click on the red button. Then, go again to the Properties Panel (Ctrl+F3) below the stage. On the left side, You will find the Instance name input field there. Call this button red_btn. See the picture below.



Do this also for every other button, but for red, type blue, brown....

Step 7

Create a new layer above the buttons layer and name it action.

Step 8

Click on the first frame of layer action and go to the action script panel (F9). Then, enter this code inside the actions panel:

red_btn.onRelease = function() {
var rimColor_color = new Color(rim_mc);
rimColor_color.setRGB(0xFF0000);
};

yellow_btn.onRelease = function() {
var rimColor_color = new Color(rim_mc);
rimColor_color.setRGB(0xFFFF00);
};

brown_btn.onRelease = function() {
var rimColor_color = new Color(rim_mc);
rimColor_color.setRGB(0x996600);
};

blue_btn.onRelease = function() {
var rimColor_color = new Color(rim_mc);
rimColor_color.setRGB(0x0099FF);
};

Test your Movie (Ctrl+Enter).

We're done!

Download source file (.fla)

Have questions about this tutorial?
Visit our friendly Community Forums!
Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!

Top tutorials

1. Advanced full flash site - Part 1
Total views: 296062

2. High-tech city animation
Total views: 246569

3. Water effect
Total views: 226666

4. Photo slide show
Total views: 209039

5. Special Picture Effect
Total views: 184616



Related links