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: 64542

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: 310911

2. High-tech city animation
Total views: 274120

3. Water effect
Total views: 237426

4. Photo slide show
Total views: 221072

5. Special Picture Effect
Total views: 190869



Related links

dans le cadre de leur collection automne / hiver 2008 de la ngc, marque japonaise a ainsi une fois de plus a porter.ADIDAS TUBULAR WOMENils ont travaillé sur l'ensemble des trois pieces et # 8211; un sac fourre - tout, une valise et un porte - clés / carte de voyage.ils présentent une gamme de produits classiques.le fait qu'elles offrent a la plupart d'entre eux en orange est un bon contraste.  via honeyee.ADIDAS ORIGINALS NMDon peut s'attendre a une libération de ce produit dans les semaines a venir.ADIDAS TUBULAR SCHUHEla broderie artiste kimberly scola est parmi ceux qui participent a ce los angeles & # 8216; & # 8220; cette fete et # 8221; exposition,ADIDAS YEEZY BOOST 550 inaugurée vendredi dernier.ADIDAS EQUIPMENT 10a l'occasion de l'ouverture, en cas de scola a collaboré avec une tapisserie de 100 faux sacs fourre - tout.Adidas Adizero F50 FGces agréables rappels d'un événement,ADIDAS X PLR malheureusement, seulement deux jours de liaison.ADIDAS MESSI 16.3 ICles points saillants de & # 8220;StartAdidas Ultra Boost Uncaged cette fete et # 8221; et une liste de cas suivent l'artiste.ADIDAS ACE 16.3 TF