Saturday, April 28, 2012

Native extension template Flash Develop IDE


Open your extension.xml and setup your native library name and path to your class in native code that extends FreExtension as initializer and id which would be used to create and identify context. Extension.createExtensionContext


Open bat/Setup.bat to set path to your FlexSDK with AIR.(AIR 3.0 or above)



You could use bat/Certificate.bat to create key to sign your native extension.


Open main entry ActionScript class and code it. (Template would auto generate it for you)



Run PackageSWC.bat. It would create swc of your interface towards native code (.jar or .a,...file) and unpack library.swf in the platform folders.






Copy your native code inside platform folder.


Update 28.08.12
If  you have resources(drawable,layout,strings...) in you Android Java project, copy them in extlib->Android-ARM->res folder so they be packed into the ane.
Run PackageAne.bat. It would create your native extension swc and unpack in "ane" folder.


If you want to add more classes beside Main.as to your swc you should edit conf/swcConfig.xml




 and add to path-element new tag with your class name (MyNewClass.as).(* def this need improvement maybe some batch to read content of "src" and change xml)


*Update 29.05.12
Extract the template downloaded from below link into Projects folder of your FlashDevelop installation.
 ex. E:\Program Files\FlashDevelop\Projects

 *Update 22.08.12
In other project where you will use created native extension from above:
1. Create folder "extdir"
2. Copy Multitouch.ane folder and Multitouch.swc inside
2a. Right Click on the  Multitouch.swc -> Add to Library
2b. Right Click on the  Multitouch.swc -> Options->External Library
3. In Run.bat add -extdir "extdir"
adl -screensize %SCREEN_SIZE% -XscreenDPI %SCREEN_DPI% "%APP_XML%" "%APP_DIR%" -extdir "extdir"
The above is for Debug and Release. If  you want to package:
1.Create folder "ane"
2. Copy Multitouch.swc (rename it to .ane)
2. Copy Multitouch..ane
3.In Package.bat add -extdir "ane"
call adt -package -target %TYPE%%TARGET% %OPTIONS% %SIGNING_OPTIONS% "%OUTPUT%" "%APP_XML%" %FILE_OR_DIR% -extdir "ane"


*Update 28.09.12  Template Packager.bat updated, "res" and "ane" folder added for packed .ane file.

*Update 09.05.13  .
1. added -platformoptions flag in command line and platformoptions.xml in iPhone-ARM folder, so additional frameworks and libs can be defined in linkeroptions
2. changed IPhone-ARM folder name to iPhone-ARM.
3. changed IPhone-ARM extension.xml to iPhone-ARM fixing problems with packaging under IOS.

*Update 06.11.13
changed acompc to compc in packaging templates

download

6 comments:

  1. First off, THANKS!!! Was starting to make my template but yours is way better than mine! I am knee deep in trying to get this work on my mac running WindowsXP on VirtuaBox.

    First thing I found was... I think line 16 in PackagerAne.bat.template missing a '$' in 'lib/(PROJECTNAME).ane'

    ReplyDelete
  2. Bug fixed. :)) Zip/Unzip might be pain point don't know if its the same between WinXP and newer windows.
    Improvement could be done in reading files in src so swc can be created(Wish you could help :). All in all Flash Develop creators or someone else need to create .dll plugin and make this rock solid.

    ReplyDelete
  3. On my end had to replace the .sh files with .bat files. and add the path to my machine's unzip command. So I was successful in creating a *.ane folder but shouldn't it be a file not a folder? This is my first extension creation attempt so my experience is well... none. I am able to get the iBattery.ane, gyroscope.ane and notifications.ane wired up and working in an iOS app. But anytime I create an .ane file it crashes on device at extension init. Which led me here to your blog. Trying to get to a successful first .ane creation. I say all this, because I will help where I can, but my skills for .ane are limited.

    ReplyDelete
  4. See picture above you would see it would create MultitouchExtension.ane in ane folder (and MultitouchExtension.swc). That's it. You can use extension as normal swc library into your project. Flash Builder 4.6 could even accept .ane file as inclusion.

    ReplyDelete
  5. In your template you have a comment
    'SWF-Version (!!!Warnning version 15 goes with 4.6 and AIR 3.2)'

    Where did you get this info?

    Page 41 of this doc http://help.adobe.com/en_US/air/extensions/air_extensions.pdf

    I see a small chart explaining swf compatibility but nothing about Air3.2 and I am actually
    trying to to test the Air3.4 beta so trying to understand the exact versions I need. Thanks in advance!

    ReplyDelete
    Replies
    1. Warning is to watch pairing of AIR SDK version with the swf-version created.
      AIR 3.3 goes with -swf-version=16 -target-player=11.3
      AIR 3.4 goes with -swf-version=17 -target-player=11.4

      Delete