开发者

flash.sensors.Accelerometer on Android within web browser

开发者 https://www.devze.com 2023-02-07 09:54 出处:网络
The Accelerome开发者_运维技巧ter UPDATE event never fires, tho isSupported returns true, when the flash app is running inside the android web browser. How can I make it work?

The Accelerome开发者_运维技巧ter UPDATE event never fires, tho isSupported returns true, when the flash app is running inside the android web browser. How can I make it work?

     this.accelerometer = new Accelerometer();
            accelerometer.addEventListener(AccelerometerEvent.UPDATE, onAccelerometerUpdate);

Ref: http://blogs.adobe.com/cantrell/archives/2010/04/simple_accelerometer_example.html

Ref: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/sensors/Accelerometer.html#isSupported

My device is Samsung Galaxy S.

It does however work as an AIR app on android.

Ref: "Adobe Forums - Accelerometer"


You declared accelerometer as a local variable, so once it is out of scope it will no longer exist. Declaring the var as a class instance member ensures its existence until you no longer need it. http://forums.adobe.com/message/3363673#3363673

The fix was to declare the Accelerometer instance as a class member instead of a local variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消