myBox.addEventListener(Event.ENTER_FRAME, moveIt);
myBox.x = 250;
function moveIt(evt:Event){
myBox.x += 3;
if(myBox.x>500){
myBox.x =250;
}
}
var counter:int = 0;
myBox.addEventListener(MouseEvent.CLICK, youClickedMe);
function youClickedMe(evt: MouseEvent){
counter ++;
trace ("Ouch, you clicked me " + counter + " times");
}
//comment for the human reader
/* BLOCK COMMENT
;
{ & }
variable
instance name
properties of object (instance) (CLASS) x, y, rotation, alpha, visible
function
function name
function parameter
event
types of event
triggering of event
event handler
operator
assignment
dot notation
IF statement
Comparison - true or not
*/
myFootball.addEventListener(MouseEvent.CLICK, ballClicked);
function ballClicked(evt: MouseEvent){
myFootball.addEventListener(Event.ENTER_FRAME, startAnimation);
}
var deltaD :Number = 10;
function startAnimation(evt: Event){
myFootball.y += deltaD;
// myFootball.x += deltaD;
if (myFootball.y <0){
deltaD = - deltaD;
}
if (myFootball.y >= 320) {
deltaD = -deltaD;
}
}
The Task
- Copy the code into ACTION pane (hand copy, not copy paste!)
- Identify the objects and create them.
- Annotate the code to indicate the function (Identify the items in the list in the block comment)
- Edit the code to change the boundaries, directions and speed.