Help with code that use accelerometer

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();
		}
}