> > Tutorials > T1036

Modify shape color with ActionScript.

change colors

Follow the steps below:

  1. Launch Flash Designer and create a blank document.
  2. Set the frame delay to “Stop” (“Frame” > “Frame Delay”).
  3. Size the frame at about 300×300 (“Frame” &gt “Frame Size”).
  4. Draw 2 circles with the “Ellipse Tool”.
  5. Select both shapes (Ctrl+A). Choose “Item” > “Line Width” > “None”.
  6. choose “Edit” > “Convert to Sprite”. The object should appear as “Sprite3”
  7. Right-click it and click “Placement Properties”.
  8. Check the “Action-Script Target” checkbox and click OK.

Next, create 2 color buttons below “Sprite3”.:

  1. Choose “Rectangle” tool and draw a small rectangle (about 18 x 18 pixels, hold CTRL to draw both edges equal)
  2. Change fill color to purple
  3. Choose “Action” > “OnClick” and enter the following ActionScript code:myColor = new Color(Sprite3);
  4. Duplicate the rectangle with “Edit” > “Duplicate”
  5. Change fill color to green
  6. Choose “Action” > “OnClick” and modify the following ActionScript code:myColor = new Color(Sprite3);
  7. Hit F9 to play the file.

Download source project

get flash