Start you Flash software. Select the "New" option from the "File" menu on the main Flash menu bar. Select the ActionScript 3 (AS3) file option on the file menu box that appears to create a new AS3 file.
Select the "Color" option from the "Window" menu on the main Flash menu bar. Position your cursor over the color map in the dialog box that appears.
Click a color to display its hexadecimal code equivalent. Look in the box that appears below the color map to locate the hexadecimal color code equivalent. Check to see that the code is preceded by the pound symbol, "#" and has 6 alphanumeric characters that follow. Note that the the six alphanumeric numbers that follow the pound sign is the hexadecimal color code corresponding to the color you selected. Use these values in your AS3 code to set and change color of objects.
Select "Actions" from the "Window" menu on the main Flash menu bar to open the Action's editor (the text display where you enter in ActionScript AS3 code).
Declare an unsigned integer(unit) variable called color in the first line and assign it a hexadecimal color code that you obtain from the color map. Use the hexadecimal color code, ff00ff (which has the highest level of red, the lowest level of blue and the highest amount of green), for this example. Type the code into the Action's editor as var color: uint = 0xff00ff;.
var color: uint = 0xff00ff;
Declare a graphics shape object named "squareColor" in the second line of code. Type the code into the Action's editor as var squareColor:Shape= new Shape(); to declare the "squareColor" shape object. .
var color: uint = 0xff00ff;
var squareColor:Shape= new Shape();
Attach a fill color to the "squareObject" shape object to fill in color within the perimeter of the shape. Use the "color" variable as the color to fill the "squareObject" shape with. Type in the third line of the Action's editor the code, squareColor.graphics.beginFill(color); to set the fill color.
var color: uint = 0xff00ff;
var squareColor:Shape= new Shape();
squareColor.graphics.beginFill(color);
Define the shape of "squareObject" as a rectangle with a lower left vertex at the point (100,100) and a upper right vertex at the point (300,300) to make a square that is 200 pixels on a side(300 minus 200 equals 100). Attach the drawRect method in the fourth line of the code to the "squareColor" object using the code, squareColor.graphics.drawRect(100,100,300, 300);.
var color: uint = 0xff00ff;
var squareColor:Shape= new Shape();.
squareColor.graphics.beginFill(color);
squareColor.graphics.drawRect(100,100,300, 300);
End the color fill with the "endFill": method in the next line of code, line 5. Type the code squareColor.graphics.endFill(); to stop the color filling process of the "squareColor" object.
var color: uint = 0xff00ff;
var squareColor:Shape= new Shape();.
squareColor.graphics.beginFill(color);
squareColor.graphics.drawRect(100,100,300, 300);
squareColor.graphics.endFill();
Place the "squareColor" object on the stage (screen) with the code, stage.addChild(squareColor);, in the sixth line of code in the Action's editor.
var color: uint = 0xff00ff;
var squareColor:Shape= new Shape();.
squareColor.graphics.beginFill(color);
squareColor.graphics.drawRect(100,100,300, 300)
squareColor.graphics.endFill();
stage.addChild(squareColor);
Select the "TestMovie" option form the "Control" menu on the main Flash menu bar to play the movie. Observe that a square is displayed on the screen with a magenta color.
Click the "close" button on the movie and change the first line of code in the Action's editor to read var color:unit = 0xff0000 to change the color of the square to red. Test the movie again. Observe that the square is now red instead of magenta.