50 likes | 136 Views
4. Plan for the course Today: Understand instance in Object oriented programming. System listener Write a function Some syntaks. Plan. Handout on …. Instans. A class (symbol in the library) is like a rubber stamp. A class is the plan for building the instance
E N D
4 Plan for the course Today: Understand instance in Object oriented programming. System listener Write a function Some syntaks
Plan • Handout on ….
Instans • A class (symbol in the library) is like a rubber stamp. • A class is the plan for building the instance • The plan describe properties and the behaviour of the instance. • Properties is variable’s • Behaviours is function’s
Ball • Make a circle to a symbol • To types of listeners System and InteractionaddEventListener(Event.ENTER_FRAME,addEventListener(KeyboardEvent.KEY_DOWN • Write this code in the symbol
var xSpeed:int; • var ySpeed:int; • var acc:int; • xSpeed =Math.random()*10-5; • ySpeed = 0; • acc=1; • addEventListener(Event.ENTER_FRAME, go); • function go (e){ • moove(); • accel(); • chek(); • } • function moove(){ • this.x=this.x+xSpeed; • this.y=this.y+ySpeed; • } • function accel (){ • ySpeed=ySpeed+acc; • } • function chek(){ • if (this.y+this.height>400){ • ySpeed=ySpeed*-1; • ySpeed++; • } • if (this.x+this.width>550 || this.x<0) { • xSpeed=xSpeed*-1; • } • }