1 Reply Latest reply on Jun 19, 2011 7:51 AM by kglad

    question about ball hit an object

    php s Level 1

      hi how can i make a ball hit an object and taht object shud resist the movment of the ball

      and the ball move by Accelerometer of mobile by useing this code


      import flash.sensors.Accelerometer; import flash.events.AccelerometerEvent; var acc:Accelerometer = new Accelerometer(); acc.addEventListener(AccelerometerEvent.UPDATE,update); var ty:int = 0; var tx:int = 0; function update(e:AccelerometerEvent):void {      tx = e.accelerationX * 20;      ty = e.accelerationY * 20; } this.addEventListener(Event.ENTER_FRAME,loop); function loop(e:Event):void {      ball.x +=((ball.x - tx)-ball.x)*0.3;      ball.y +=((ball.y + ty)-ball.y)*0.3;      }


      and how can the wall resist this movment by using the code of drag and drop of the ball also by this code


      var dragArea:Rectangle = new Rectangle(0,0,stage.stageWidth,stage.stageHeight); ball.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_7); function fl_ClickToDrag_7(event:MouseEvent):void { ball.startDrag(true, dragArea); } stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_7); function fl_ReleaseToDrop_7(event:MouseEvent):void {      ball.stopDrag(); }