Flash Professional is a great tool to create games and animations, but also to make native apps for iOS and Android. Version 3 of Air introduces native extensions, which allow you to access platform specific features like the gyroscope or push notofications.

I recorded a video tutorial to show you how to install (overlay) the Air 3 SDK for Flash professional, create an ActionScript project that links to a native extension, compile using ADT in the command line and install the IPA file on your device. Below this video you’ll find the code and links I used. Many thanks to iBrent for his tutorials.



 

  • Download the Air 3 SDK.
  • Check where to place the Air SDK files.
  • Download some native extensions from Adobe or third parties.
  • Create a Flash AS3 project (iOS), add the SWC from the native extension to your Library paths, select “External” link type.
  • Use the code from the extension sample in your app. Mine started with g1 = new Gyroscope();
  • Add the native extension ID to your app descriptor, like <extensions><extensionID>com.adobe.gyroscope</extensionID> </extensions>
  • Try to publish, which fails. The SWF is created though.
  • Build a directory using swf, app descriptor, p12, mobile provisioning file and a directory holding your extension.
  • Navigate to this directory using the terminal, then create a command that will compile. Check the list of options. Mine was SDK/bin/adt -package -target ipa-test-interpreter -storetype pkcs12 -provisioning-profile dev.mobileprovision -keystore Apple_dev_cert_export.p12 gyro.ipa gyro-app.xml gyro.swf -extdir exDir

Have fun using native extensions!

Getagd met:
 

15 Antwoorden op Native AIR Extensions in Flash

  1. Very nice video. I keep meaning to try to integrate with native extensions, but never really got around to. Your video shows the process it’s not so daunting.

    Thanks for that.

  2. Danel zegt:

    I love your way to explain it all, its like bed-time story very dramatic :D (of course not in a bad way!)

    Anyhow thanks for the video, ive tried extensions on iOS before in FP and did not manage to get i work, ill try again with your video as reference!

    /Danel

  3. sander zegt:

    Great that this video has helped you guys! I’ll create some more while I work on my iPad pinball game.

    Extra tip: once you have the gyroscope .ane working, you can use it do differentiate between iOS devices. For instance: if the screen size is 768*1024 and gyroscope is supported, you have detected iPad2 and can activate heavier graphics.

  4. Konstantin Elstner zegt:

    Hi,
    thank you for this great simple video.
    Simply real better as the irritating “howtos” at adobe.com.

  5. some guy zegt:

    AHH!! thank you! I was thinking the error generated in flash was causing me a problem. Once your video advised it was not, i found my issue and was able to get everything working fine! THANKS!!!

  6. Paul Steven zegt:

    I have the following code in my Flash file


    import com.adobe.nativeExtensions.Gyroscope;
    import com.adobe.nativeExtensions.GyroscopeEvent;

    import flash.events.Event;
    import flash.events.MouseEvent;

    var g1 = new Gyroscope();

    But get the error

    [SWF] gyroscope_test.swf – 2182 bytes after decompression
    ReferenceError: Error #1065: Variable com.adobe.nativeExtensions::Gyroscope is not defined.
    at gyroscope_test_fla::MainTimeline/frame1()[gyroscope_test_fla.MainTimeline::frame1:7]

    Any ideas?

    • sander zegt:

      Looks like a runtime error on the ADT simulator, am I right? I suppose the Objective-C code inside the native extension cannot run on your desktop. Have you tried running the app on your iOS device?

      Also double-check if the extension was compiled into your .IPA. Here’s a simpl trick:
      rename the .ipa file to a .zip file.
      Unzip.
      Navigate to the payload.app.
      Right click > Show package contents.
      Check if the .ane was included in you app

      Hope this helps!

  7. mike zegt:

    Thank you for this great tutorial.
    It works.
    I have one question with the images – you mention it in the tut, but at the end you don’t show.
    I tried all paths, but the console always says: Icon myiconname_114x114.png is missing from package.
    How will I insert the icon names or paths inside the xml file so that they will be found.
    Using the flash publish function will work with icons but as you say, using the terminal is much faster, but no icons.

    • sander zegt:

      I like to place my icons in a folder called “icons”, and refer to them in the Application Descriptor XML as icons/icon_48.png. However: I haven’t managed to get this working using the command line. Instead, I put them in the same folder as the swf file. In the command, I refer to the files without any folder name. I have corrected my Application Descriptor XML to do the same. It’s messy, but it works :-)

  8. mike zegt:

    …tried to put them inside the swf-folder, but still no success. Seems the terminal compiler can’t find the icons images.

    But using the terminal for compiling is so damn fast compared to compiling it from inside Flash.
    So thanks for that trick – it saves me hours.

    • sander zegt:

      I actually migrated to Flash Builder. I make my assets in Flash pro, export as swc. Builder has only code. Compiles an AIR mobile test-version in seconds, since it doesn’t have to compress bitmaps and vectors. Flash applies a ZIP-like function to a SWF, to reduce text and vectors. If the assets are already in the SWC, compiling is much faster. Exporting an ad-hoc distribution .IPA is still about 2 minutes on my old iMac though… When new iMacs come out, I’m hoping to reduce that to 40 sec :-)

  9. mike zegt:

    Yes, Flash Builder. I always wanted to give that a try too.

    sander, do you also have experience with profiles?

    I built a distribution profile in the apple developer page to let people test my Apps by sending them the .ipa as an email attachment.
    I did the following:
    1) They gave me their UDID from their device
    2) I used that ID to produce a distribution profile as mentioned above.
    3) they installed that profile to their device by dragging it to their iTunes and sync with their device.
    4) I used the certificate and that distribution profile to compile the App ipa
    But:
    the app can’t be synced to their device. “AppName can’t be installed”
    They installed the profile, they see it in their device.
    Am I missing something?
    I can install it on my own device, but I also have developer profiles installed.
    Do i need both profiles on the testers device – developer and distribution profile?

    • sander zegt:

      Hey Mike!

      I read the error says “AppName can’t be installed”, which suggests the name of your app is “AppName”. I can image that’s not what you want. Have you tried editing the IOS properties in the Publish Settings? I’m not sure this is the reason for the error.

      You don’t need dev profiles on tester devices, just the distribution profile and the .IPA. If the process works for you and not for the testers, try comparing devices. Is their hardware older than yours? Is their OS version too low? I seem to remember AIR doesn’t support iOS3 anymore, could that be it?

      Hope this helps! Sander.

  10. mike zegt:

    AppName was only a placeholder for WhateverNameforMyApp. I sorted this out by starting new, there seemed to be a (known) problem with certificates after upgrading to Lion.

    Do you think you could post your gyroscope .fla for downloading as well, as I still have some problems with the var g1 = new Gyroscope(); – giving me no result.

    • sander zegt:

      Code will be difficult: SDK and files are scattered. If you get a compile-time error, you need to give Flash access to the source code for validation. Try adding the SWC or ANE to the Library paths in AS3 settings in compiler settings. If it’s a runtime error on the desktop: that’s normal! Your desktop can’t find the iOS hardware or API that the ANE is referring to! Hope this helps.

Niet mee eens? Wel mee eens? Vertel!

(je e-mailadres zal niet publiek getoond worden)

*

De volgende HTML tags en attributen zijn toegestaan: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Quick contact

Mechelsesteenweg 47, 2018 Antwerpen
+32 477 90 17 29,

Blog

Recent geblogd: Hoe kan je via Flash iPad apps maken die iOS specifieke features aanspreken, zoals de gyroscoop?

Copyright

De afbeeldingen en animaties die u hier ziet, zijn geplaatst met toestemming van de opdrachtgever. U mag niets overnemen zonder de toestemming van Swörl.