Adobe AIR Gyroscope Native Extension with Euler Angles (roll, pitch, yaw) for iOS


UPDATE: I have released the extension including source on google code with some changes.
Euler Gyroscope ANE on Google Code

I baked my very first AIR iOS Native Extension. It’s just an adapted version of this version from Adobe. Because in my opinion the data of radians per second aren’t really good to handle. So I looked into Apples API documentation and found out that there are Euler Angles in the CMMotionManager CMDeviceMotion classes. So I just changed a few lines in the Objective-C Code. I learned much from this tutorial Native Extionsion for Adobe AIR and iOS 101 by Liquid Photo

NSString *myStr = [NSString stringWithFormat:@"%f&%f&%f&%f&%f&%f", 

[motionManager startDeviceMotionUpdates];

motionManager.deviceMotionUpdateInterval = 0;

And added these three parameters roll, pitch and yaw to the Actionscript Gyroscope Event.

new GyroscopeEvent(GyroscopeEvent.UPDATE, _x, _y, _z, _roll, _pitch, _yaw)

You can download source and final iOS .ane Native Extension file here:
iOS Air Native Extension Gyroscope – with Euler Angles

Be Sociable, Share!

This entry is filed under Adobe AIR, Adobe Flash Platform, iPad, iPhone. And tagged with , , , , , , , , , , , , , . You can follow any responses to this entry through RSS 2.0. You can leave a response, or trackback from your own site.

24 Responses to “Adobe AIR Gyroscope Native Extension with Euler Angles (roll, pitch, yaw) for iOS”

  1. Donny

    Thanks for your efforts with this extension. It works great!

  2. marco

    I package an iOS app with the native extension for gyroscope (

    in this way

    ipa-test-interpreter ALL OK

    ipa-test iPhone 4s crash.


    Another question.

    I monitor my app with Stats and

    framerate is 60/60

    MS is 20/30

    memory 4.000 more or less

    but gyroscope does not uptade values properly.

    is it possible that “interpreter” mode reduces native extension performance ?

    thanks in advance


  3. webfraggle


    I tested the extension only with ipa-debug (developer provisioning profile) and ipa-ad-hoc (ad hoc profile). Both worked very well. And yes test-interpreter is very slow because actionscript code is interpreted on-the-fly and converted to native binary code.

    Hope this helps.

  4. Richard

    you got ipa-ad-hoc to work? i’m having the same trouble. seems for me interpreted actionscript works but translated not. is there something else that adt needs? -platformsdk or something? my ant looks like the following…





    i’d really like to know how you got it not crashing on ipa-ad-hoc


  5. Richard

    sorry.. ant looks like..





  6. Richard

    i’ve got it working! solution is simple. for ipa-ad-hoc or ipa-app-store (translated code) the Gyroscope.swc should be removed from exports! just like you’ve described here..


  7. webfraggle

    Hi Richard

    Congratulations that you have ist working now. And yes that’s it. The swc has to be removed from exports.

  8. Richard

    hallo Christoph.. now i’ve got it working i’ve done a lot of testing using an ipad2 and 3. i’m finding both your gyroscope extension and Adobe’s returns very inconstant values for GyroscopeEvent.UPDATE. i’m not sure but it seems if the device is held very still when the app loads it works fine but if the device is moving around at the time the gyro is initialized it has trouble sending accurate readings. also, when pressing the ios home button, going back to the desktop then back into the app, the gyro also seems to lose it’s senses. would be great if this worked as well as the accelerometer does and even better if it was built into the AIR runtime by default. perhaps we get it in AIR 3.4.
    anyway.. would be great to know if you are having the same issues or if it’s working smoothly.
    just looking at the numbers doesn’t give much of a clue if it’s working accurately so i set up a looping background that is moved left and right by the gyro readings (rendered with the Starling framework, it’s very smooth).. so for example.. holding the device and spinning around in your chair will move the background. looks awesome when it works! especially scrolling several images to give a parallax effect. but not consistant enough to publish :(

    aber vielen dank fuer dir information.. hoeffentlich es kommt mit air 3.4

  9. Kirit

    First, thanks to Christoph for this great extension. Euler angles are a lot more helpful than radians/sec :)
    We had a problem earlier, but thats resolved. Sharing as it might help others -
    Since the angles are returned in a range of -180 to +180 … it is helpful to add 2 PI when values are negative so you get a smooth 0 to 360. Now it works well.
    We’ve run into another problem -
    Does somebody know how to deal with the sudden changed when panning the phone up & down i.e. the pitch affects the yaw! This results in sudden movements.

    Thanks for any suggestions.

  10. Jackisgames

    I cant get it to work, the EulerGyroscope.isSupported keep returning false
    And the update event is not fired
    Is there’s any sample project that i can look for? :(

  11. Jordan

    Hey Christoph, thanks for the wonderful extension!

    I’ve managed to get it running, but I’m having the same problem as Richard, where the gyroscope reading seems to be delayed or sometimes not reading at all. I’m also having trouble trying to access the x y z values through the EulerGyroscope class, as if it’s not there.

  12. webfraggle

    Oh, sorry that i’m answering so late. My spam filter deleted the notifications.

    Sample code can be found in the repository on google code:

  13. webfraggle

    Hello Jordan.

    I can’t say anything about the delay. It’s just like the example extension from adobe. I’m only passing the roll, pitch and yaw to the action script. So there are no x,y,z values.

  14. Kirit

    We were building our app in portrait mode and realized that there are sudden movements when panning the phone up and down resulting in uncanny movement. The Gyroscope works best in Landscape orientation. Now, we’ve run into a new problem… iOS6! Has anyone else run into any problems with iOS6 using the native Gyroscope or this extension?

  15. Kirit

    There are some errors when publishing with AIR SDK 3.4 (required for iOS 6 compatibility)
    @webfraggle there is known issue which affects certain extensions, details & temporary fix both can be found here –

  16. webfraggle


    I haven’t tested it with AIR3.4 and I have not enough time to do it in the next weeks. But, all the code is on my SVN repository and maybe someone else can do the changes. I will be happy if the changes can be shared and put back into the SVN and the extension.

    My last info about 3.4 and iOS 6 is that it is only available on labs an it isn’t possible to publich to the AppStore with this beta version.

  17. Kirit

    AIR 3.4 has been released and it supports iOS 6 with these known issues -

    After digging deeper this is what we’ve learned -
    We are using a Camera feed and thus to benefit from AIR 3.4′s ability to GPU accelerate it, we tried to use StageVideo’s attachCamera and found that this breaks the Gyroscope functionality. Maybe this problem will also affect those using Stage3D too? If we instead use the regular Video object to display the camera, the extension is working well with AIR 3.4.

  18. theguaz

    Hey, i’m doing an AR app that uses this extension; and i succesfully created the app for IOS6, using air 3.4 no errors occured, but i experienced a huge lag as i added features to my app (transparent videos, stagevideo.AttachCamera).

    As result of that i finally splitted the whole app into 2 devices, an ipod touch that has the gyroscope and informs to the other device of its orientation using RTMFP.

    I would like to share thoughts on this matter with you. I have a ton of results and things to ask about this extension.


  19. webfraggle

    Hi Luis

    I’m very interested in your results and information. But for the next days I’m on holidays. If you want you can send ne an email. And if I’m allowed I can add these information to this article or to the google code page. Have you made changes to the code? If you want you can have write access to the SVN.

    Thanks Christoph

  20. Kirit

    We’ve built the app and published to the AppStore but the only problem seems to be with iPhone 4 running iOS 6. Not sure what is causing this … are there any known incompatibilities? @theguaz is your app working fine on iPhone 4 with iOS 6?

  21. Jan


    I am receiving the follwoing error when building the app with Flash CS6@Windows7:

    Adobe Flash Professional
    Error creating files.

    ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _llvm_unwind from AOTBuildOutput-0.o. To fix this warning, don’t compile with -mdynamic-no-pic or link with -Wl,-no_pie

    ld: warning: multiple L$start$ labels found at same address in __ZN9NetStream12DispatchProcEP10NativeInfo at offset 0x06C0

    Any ideas what this error is and how I can avoid it?

  22. webfraggle


    This is just a warning. I also have this warning with some native extensions. The App should work anyway.


  23. Torkiel

    @Kirit did you find out deal with the sudden changed when panning the phone up & down i.e. the pitch affects the yaw ?

  24. Yang,HS

    works very great compare to the accelerometer value provide by AS3! Thanks for ur ANE!