Selteco.com >
FlashDesignerZONE.com >
Tutorials > T1036
Modify shape color with ActionScript.
Follow the steps below:
- Launch Flash Designer and create a blank document.
- Set the frame delay to "Stop" ("Frame" > "Frame Delay").
- Size the frame at about 300x300 ("Frame" > "Frame Size").
- Draw 2 circles with the "Ellipse Tool".
- Select both shapes (Ctrl+A). Choose "Item" > "Line and Fill" > "Line Width" > "None".
- choose "Edit" > "Convert to Sprite". The object should appear as "Sprite3"
- Right-click it and click "Placement Properties".
- Check the "Action-Script Target" checkbox and click OK.
Next, create 2 color buttons below "Sprite3".:
- Choose "Rectangle" tool and draw a small rectangle (about 18 x 18 pixels, hold CTRL to draw both edges equal)
- Change fill color to purple
- Choose "Item" > "Actions" > "OnClick" and enter the following ActionScript code:
myColor = new Color(Sprite3);
myColor.setRGB(0xff00ff);
- Duplicate the rectangle with "Edit" > "Duplicate"
- Change fill color to green
- Choose "Item" > "Actions" > "OnClick" and modify the following ActionScript code:
myColor = new Color(Sprite3);
myColor.setRGB(0x00ff00);
- Hit F9 to play the file.
Download source project t1036.zip