# Help with code that use accelerometer

**URL:** <https://forum.kirupa.com/t/help-with-code-that-use-accelerometer/544379>\
**Category:** flash\
**Created:** [February 18, 2015, 4:53am UTC](https://forum.kirupa.com/t/help-with-code-that-use-accelerometer/544379 "2015-02-18T04:53:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unit7](https://avatars.discourse-cdn.com/v4/letter/u/919ad9/32.png) [@unit7](https://forum.kirupa.com/u/unit7)\
**Post date:** [February 18, 2015, 4:53am UTC](https://forum.kirupa.com/t/help-with-code-that-use-accelerometer/544379/1 "2015-02-18T04:53:23Z")

</div>

I am working on an android app and im stucked with the code. Need to make a code that measures the power of shake (accelerometer) in the lenght of time and send us to scene 1, 2 or 3

Assuming that:  
scene 1 = 0.1 - 1.0  
scene 2 = 1.1 - 2.0  
scene 3 = 2.1 \<

If we get the highest power of shake 1.6 in the lenght of time (3 or 5 seconds)  
then app will send us to scene 2, if we get highest 0.6 then scene 1

**Please help or give some links to tutorials or something usefull.**

This is my actual code that let me go to next frame when device detects 0.9 of shake power

```
stop();

var fl_Accelerometer_4:Accelerometer = new Accelerometer();
fl_Accelerometer_4.addEventListener(AccelerometerEvent.UPDATE, fl_AccelerometerUpdateHandler_4);

function fl_AccelerometerUpdateHandler_4(event:AccelerometerEvent):void

{	
	var threshold:Number = 0.9;
	if ((event.accelerationX > threshold && event.accelerationY > threshold) ||
		(event.accelerationX > threshold && event.accelerationZ > threshold) ||
		(event.accelerationY > threshold && event.accelerationZ > threshold)
		)
		
		{
		MovieClip(this.root).nextFrame();
		}
}
```
