gavin sim logo
 

Basic - week 1

Week 2

Week 3

Week 4

Week 5

Week 6

Week 7

Teaching > Flash notes

More Conditionals

Download monster.fla

Open the fla and on the actions layer type the following in the actions panel

var moveSpeed:uint = 5; // speed monster will move
var hitSide:Boolean = false;


stage.addEventListener(Event.ENTER_FRAME, moveMonster);
  
function moveMonster(event:Event):void{
   monster.x +=moveSpeed;
}

The first line is a variable that controls the speed the alien moves across the stage. The second variable will be used later to see if the monster has reached the other end.

The event listener is then created and attached to the stage, the event is a enter frame and this will be called continously calling the function moveMonster. The movieclip with an instance name of monster then has its x position incremented by the value of the moveSpeed variable.

Control / Test Movie

Excercise

Using the code fom the lecture slides see if you can get the monster to move left and right across the stage.