All pastes #352312 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-12 19:07 UTC
rendered paste body
//fla file code, fla has a movieclip named circle on stage
stop();
var myBouncer:Bouncer = new Bouncer(circle, 3, 2);
myBouncer.startMoving();


//Mover class code
class Mover extends MovieClip{
	var objectRef:Object;
	var targetMC:MovieClip;
	var xVel:Number;
	var yVel:Number;
		
	function Mover(targetMC:MovieClip, xVel:Number, yVel:Number){
		this.targetMC = targetMC;
		this.targetMC.objectRef = this;
		this.xVel = xVel;
		this.yVel = yVel;
	}
	
	function updatePosition(){
		this._x += this.objectRef.xVel;
		this._y += this.objectRef.yVel;		

	}
	
	function startMoving(){
		this.targetMC.onEnterFrame = this.updatePosition;
	}
	
	function stopMoving(){
		this.targetMC.onEnterFrame = null;
	}
}

//Bouncer class code
class Bouncer extends Mover {
	function Bouncer(targetMC:MovieClip){
		super(targetMC, xVel, yVel);
	}
}