# Flash CS5 iOS Acceleration

**URL:** <https://forum.kirupa.com/t/flash-cs5-ios-acceleration/326844>\
**Category:** flash\
**Created:** [January 16, 2012, 11:57am UTC](https://forum.kirupa.com/t/flash-cs5-ios-acceleration/326844 "2012-01-16T11:57:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chiklad](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@Chiklad](https://forum.kirupa.com/u/Chiklad)\
**Post date:** [January 16, 2012, 11:57am UTC](https://forum.kirupa.com/t/flash-cs5-ios-acceleration/326844/1 "2012-01-16T11:57:08Z")

</div>

hi all? i’m new to flash. And i wanted to create maze game with acceleration for iOS. But i don’t  
know how to create boundary which is stoping AccelerationX, AccelerationY. Help ME???  
here is code:  
import flash.sensors.Accelerometer;  
import flash.events.AccelerometerEvent;  
import flash.utils.Timer;  
import flash.events.TimerEvent;  
import flash.events.Event;

stop();  
var isFalling:Boolean = false;  
var theAcc:Accelerometer = new Accelerometer();  
theAcc.setRequestedUpdateInterval(10);  
var rad:Number;  
rad = ball.width / 2;  
theAcc.addEventListener(AccelerometerEvent.UPDATE, onAccUpdate);  
function onAccUpdate(e:AccelerometerEvent):void{  
ball.x += (e.accelerationX \* 10);  
ball.y -= (e.accelerationY \* 10);  
shadowBall.x = ball.x + 20;  
shadowBall.y = ball.y + 20;  
dummyBall.x = ball.x;  
dummyBall.y = ball.y;

```
if(ball.x - rad &lt; 0){
	ball.x = 0 + rad;
} else if(ball.x + rad &gt; stage.stageWidth){
	ball.x = stage.stageWidth - rad;
}

if(ball.y - rad &lt; 0){
	ball.y = 0 + rad;
} else if(ball.y + rad &gt; stage.stageHeight){
	ball.y = stage.stageHeight - rad;
}

if(dummyBall.hitTestPoint(hole.x, hole.y, true) && isFalling == false){
	isFalling = true;
	hole.gotoAndPlay(2);
	ball.visible = false;
	shadowBall.visible = false;
	dummyBall.visible = false;
	resetTimer.start();
}
if(dummyBall.hitTestObject(Bound)){
	//i think i need to ADD STOPING ACCELERATIONX, ACCELERATIONY CODE HERE.
            // but i don't know how to write it. HELP ME???
}

```

}

var resetTimer:Timer = new Timer(2000, 1);  
resetTimer.addEventListener(TimerEvent.TIMER\_COMPLETE, resetBoard);  
function resetBoard(event:TimerEvent):void{  
hole.gotoAndStop(1);  
ball.visible = true;  
shadowBall.visible = true;  
ball.x = 160;  
ball.y = 320;  
shadowBall.x = ball.x + 20;  
shadowBall.y = ball.y + 20;  
isFalling = false;  
}
