Start the Flash program. Click "New" from the "File" menu on the main Flash menu bar. Click the file type "Flash File(ActionScript 3.0)" from the "New document" dialog box that appears. Click the "OK" button to close the dialog box.
Select the "Actions" option from the "Window" menu on the main Flash menu bar to open the "Actions" editor. Position your cursor on the first line of the "Actions" editor. Click and type the code to declare a movie clip object called "myStar" on the the first line of the editor:
var myStar:MovieClip = new MovieClip();
Type the code listed below starting on the next line in the "Actions" editor to instruct Flash to: draw the star using a 1 pixel line width with the "lineTo," "moveTo" and "color fill" methods; position the star on the stage at the X,Y coordinate 200, 250 and place the star on the stage when the movie begins to play.
myStar.graphics.lineStyle(1);
myStar.graphics.moveTo(-50,-50)
myStar.graphics.beginFill(0xFF0000);
myStar.graphics.lineTo(50,0);
myStar.graphics.lineTo(-50, 50);
myStar.graphics.lineTo(0,-50);
myStar.graphics.lineTo(50,50);
myStar.graphics.lineTo(-50,0);
myStar.graphics.lineTo(50, -50);
myStar.graphics.lineTo(0,50);
myStar.graphics.lineTo(-50, -50);
myStar.graphics.endFill();
myStar.x = 200;
myStar.y = 250;
addChild(myStar);
stage.addEventListener(Event.ENTER_FRAME, rotatestar);
function rotatestar(e:Event):void
{
myStar.rotation = 1 + myStar.rotation
}
Type the code below starting on the next line of the "Actions" editor to rotate the star about its center point 1 degree clockwise every time a new frame (set periods of time) is entered using the ENTER_FRAME event and attaching a rotation property to the star.
stage.addEventListener(Event.ENTER_FRAME, rotatestar);
function rotatestar(e:Event):void
{
myStar.rotation = 1 + myStar.rotation
}
Review the code typed in, as listed below, for syntax errors and correct any errors as necessary. Copy and paste the code below if you did not type in the code and you want to ensure that the star animation runs correctly, without any errors.
var myStar:MovieClip = new MovieClip();
myStar.graphics.lineStyle(1);
myStar.graphics.moveTo(-50,-50)
myStar.graphics.beginFill(0xFF0000);
myStar.graphics.lineTo(50,0);
myStar.graphics.lineTo(-50, 50);
myStar.graphics.lineTo(0,-50);
myStar.graphics.lineTo(50,50);
myStar.graphics.lineTo(-50,0);
myStar.graphics.lineTo(50, -50);
myStar.graphics.lineTo(0,50);
myStar.graphics.lineTo(-50, -50);
myStar.graphics.endFill();
myStar.x = 200;
myStar.y = 250;
addChild(myStar);
stage.addEventListener(Event.ENTER_FRAME, rotatestar);
function rotatestar(e:Event):void
{
myStar.rotation = 1 + myStar.rotation
}
Click the "Test Movie" option from the "Control" menu to play the movie of the rotating star. Observe that the star rotates continually about its center and that the star is partially and symmetrically filled with the colors red and white.