flash.sensors.Accelerometer on Android within web browser

早过忘川 提交于 2019-12-10 23:32:31

问题


The Accelerometer 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"


回答1:


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.



来源:https://stackoverflow.com/questions/4848572/flash-sensors-accelerometer-on-android-within-web-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!