Simple Graphics - 05graphics.flaThis program creates a movie clip and puts some shapes into it.
|
|
Place a button onto your canvas. See lesson 01 step 11 for a reminder on how to do this. The code below creates an empty movie clip. You can plot your graphics into this clip. Open the Actions - Movie Clip view and enter this code.
on (release)
{
_root.createEmptyMovieClip("myTriangles", 1);
with (_root.myTriangles) {
lineStyle(2, 0x00ee00, 100); // 2 thickness, 0x00ee00 colour, 100% alpha
beginFill(0x00cc00, 50); // 0x00ee00 colour, 50% alpha
moveTo(50, 50); // Start position
lineTo(200, 150); // Straight line to this position
lineTo(80, 210); // Straight line to this position
endFill(); // Complete the path and do the fill
lineStyle(5, 0xff0000, 100); // 2 thickness, 0xff0000 colour, 100% alpha
beginFill(0xff0000, 50); // semi transparent 0xff0000 colour, 50% alpha
moveTo(100, 100); // Start position
lineTo(300, 120); // Straight line to this position
lineTo(20, 150); // Straight line to this position
endFill(); // Complete the path and do the fill
}
} Setting ColoursColours are set with hexadecimal numbers. You could use a normal number
but there is no obvious logic to the colours. Using hexadecimalHere is a hexadecimal number 0xFFCC22. The "0x" indicates that the number is hexadecimal. The next two digits represent the amount of red in the colour. The middle two digits represent the amount of green in the colour. The final two digits represent the amount of blue in the mix. Hexadecimal numbers are written down using the following symbols " 0 1 2 3 4 5 6 7 8 9 A B C D E F " 00 represents none of the colour Here are come common colours 0x000000 = Black |
Here is the finished program.
To run this again, refresh your page. You can download the source code. |
Task
|
© C N Bauers (2004) - You may use these materials for your self education. Educational institutions may use these materials too.