how to create an throwing ball game in as3
i have this AS code which i TRIED to change from http://circlecube.com/2007/03/gravity/

    package {

	import flash.display.*;
	import flash.events.*;
	import flash.ui.Mouse;
	import flash.events.*;

	public class Bag extends MovieClip {

		var timer:Number=0;
		var initialPos:Number=0;
		var finalPos:Number=0;
		var currentPos:Number=0;
		var initialSpeed:Number=0;
		
		var dragging:Boolean = false;
		var gravity:Number=2;
		var drag:Number=.99;
		var bounce:Number=.8;
		var xVel:Number;
		var yVel:Number;
		var oldX:Number;
		var oldY:Number;
		
		
		
		function Bag() {
			startFallingBall();
			initListener();
		}
		

		function moveBallDown(e:Event) {
			timer+=1;

			this.y = initialPos + .5 *(timer * timer);
			checkBottomBoundary();
		}

		function moveBallUp(e:Event) {
			timer+=1;

			var posA=this.y;

			this.y = currentPos - initialSpeed*timer + .5*(timer * timer);

			var posB=this.y;

			checkTopBoundary(posA, posB);
		}

		function checkBottomBoundary() {
			if (this.y+this.height>stage.stageHeight) {
				finalPos=this.y;

				stopFallingBall();
			}
		}

		function checkTopBoundary(firstPos:Number, secondPos:Number) {
			if (secondPos>firstPos) {
				stopRisingBall();
				startFallingBall();
			}
		}

		function startFallingBall() {
			timer=0;
			initialPos=this.y;
			this.addEventListener(Event.ENTER_FRAME, moveBallDown);
		}

		function stopFallingBall() {
			this.removeEventListener(Event.ENTER_FRAME, moveBallDown);


			if (finalPos-initialPos<.1*this.height) {
				stopRisingBall();
			} else {
				startRisingBall();
			}
		}

		function startRisingBall() {
			initialSpeed=Math.sqrt(Math.abs(finalPos-initialPos));
			timer=0;

			currentPos=this.y;

			this.addEventListener(Event.ENTER_FRAME, moveBallUp);
		}

		function stopRisingBall() {
			this.removeEventListener(Event.ENTER_FRAME, moveBallUp);
		}

		function stopEverything() {
			this.removeEventListener(Event.ENTER_FRAME, moveBallUp);
			this.removeEventListener(Event.ENTER_FRAME, moveBallDown);
		}
		
		function handleDown(evt:MouseEvent){
			this.startDrag();
			dragging = true;
		}
		
		function handleUp(evt:MouseEvent){
			this.stopDrag();
			dragging = false;
			startFallingBall();
		}
		
		function update(evt:MouseEvent){
			if(dragging){
				
				this.y += yVel;
				this.x += xVel;
				yVel = yVel * drag + gravity;
				xVel = xVel * drag;
			}else{
				xVel = this.x - oldX;
				yVel = this.y - oldY;
				oldX = this.x;
				oldY = this.y;
			}
			
		}
		function initListener(){
			this.addEventListener(MouseEvent.MOUSE_DOWN,handleDown);
			this.addEventListener(MouseEvent.MOUSE_UP,handleUp);
			//this.addEventListener(Event.ENTER_FRAME,update);
		}
		
		
	}
}


but, i think you guys can see there are problems but i can't :( can someone guide me through making this?

how to create an throwing ball game in as3
===

i have this AS code which i TRIED to change from http://circlecube.com/2007/03/gravity/

    package {

	import flash.display.*;
	import flash.events.*;
	import flash.ui.Mouse;
	import flash.events.*;

	public class Bag extends MovieClip {

		var timer:Number=0;
		var initialPos:Number=0;
		var finalPos:Number=0;
		var currentPos:Number=0;
		var initialSpeed:Number=0;
		
		var dragging:Boolean = false;
		var gravity:Number=2;
		var drag:Number=.99;
		var bounce:Number=.8;
		var xVel:Number;
		var yVel:Number;
		var oldX:Number;
		var oldY:Number;
		
		
		
		function Bag() {
			startFallingBall();
			initListener();
		}
		

		function moveBallDown(e:Event) {
			timer+=1;

			this.y = initialPos + .5 *(timer * timer);
			checkBottomBoundary();
		}

		function moveBallUp(e:Event) {
			timer+=1;

			var posA=this.y;

			this.y = currentPos - initialSpeed*timer + .5*(timer * timer);

			var posB=this.y;

			checkTopBoundary(posA, posB);
		}

		function checkBottomBoundary() {
			if (this.y+this.height>stage.stageHeight) {
				finalPos=this.y;

				stopFallingBall();
			}
		}

		function checkTopBoundary(firstPos:Number, secondPos:Number) {
			if (secondPos>firstPos) {
				stopRisingBall();
				startFallingBall();
			}
		}

		function startFallingBall() {
			timer=0;
			initialPos=this.y;
			this.addEventListener(Event.ENTER_FRAME, moveBallDown);
		}

		function stopFallingBall() {
			this.removeEventListener(Event.ENTER_FRAME, moveBallDown);


			if (finalPos-initialPos<.1*this.height) {
				stopRisingBall();
			} else {
				startRisingBall();
			}
		}

		function startRisingBall() {
			initialSpeed=Math.sqrt(Math.abs(finalPos-initialPos));
			timer=0;

			currentPos=this.y;

			this.addEventListener(Event.ENTER_FRAME, moveBallUp);
		}

		function stopRisingBall() {
			this.removeEventListener(Event.ENTER_FRAME, moveBallUp);
		}

		function stopEverything() {
			this.removeEventListener(Event.ENTER_FRAME, moveBallUp);
			this.removeEventListener(Event.ENTER_FRAME, moveBallDown);
		}
		
		function handleDown(evt:MouseEvent){
			this.startDrag();
			dragging = true;
		}
		
		function handleUp(evt:MouseEvent){
			this.stopDrag();
			dragging = false;
			startFallingBall();
		}
		
		function update(evt:MouseEvent){
			if(dragging){
				
				this.y += yVel;
				this.x += xVel;
				yVel = yVel * drag + gravity;
				xVel = xVel * drag;
			}else{
				xVel = this.x - oldX;
				yVel = this.y - oldY;
				oldX = this.x;
				oldY = this.y;
			}
			
		}
		function initListener(){
			this.addEventListener(MouseEvent.MOUSE_DOWN,handleDown);
			this.addEventListener(MouseEvent.MOUSE_UP,handleUp);
			//this.addEventListener(Event.ENTER_FRAME,update);
		}
		
		
	}
}


but, i think you guys can see there are problems but i can't :( can someone guide me through making this?
