1013: The private attribute may be used only on class property definitions.
This error is just making me wanna commit ![]()
where have i gone wrong? Help would be awesome
package classes
{
import flash.display.Sprite;
import flash.events.Event;
public class MYball extends Sprite {
// Constants:
// Public Properties:
// Private Properties:
private var _vx,
_vy,
_radius:Number ;
private var yspeed:int = 4;
private var xspeed:int = 4;
// UI Elements:
// Initialization:
public function MYball(x:Number, y:Number,
vx:Number=4, vy:Number=4){
this.x = x;
this.y = y;
this._vx = vx;
this._vy = vy;
this._radius = this.width / 2;
configUI();
this.addEventListener(Event.ENTER_FRAME, drop);
this.addEventListener(Event.ENTER_FRAME, bounce);
}
// Public Methods:
// Protected Methods:
private function drop (e:Event) {
if (this.y < (stage.stageHeight - (this.width /2))) {
this.y += this.yspeed ;
}
trace (this.y) ;
}
protected function configUI():void { }
}
// Private Methods:
private function bounce (e:Event) {
this.x += this._vx ;
this.y += this._vy ;
// IF BALL HITS LHS OR RHS THEN
if ((this.x + this._radius >= stage.stageWidth) ||
(this.x - this._radius <= 0)) {
// REVERSE ITS X DIRECTION
this._vy*= -1 ;
}
// IF BALL AT TOP OR BOTTOM THEN
if ((this.y + this._radius >= stage.stageHeight) ||
(this.y - this._radius <= 0)) {
// REVERSE ITS DIRECTION
this._vx*= -1;
}
// REVERSE ITS Y DIRECTION
}
public function get radius():Number {
return this._radius ;
}
public function get vx():Number {
return this._vx;
}
public function set vx(i:Number) {
if (i<20) {
this._vx = i ;
} else {
this._vx = 20 ;
}
}
}
}
