Start learning with our library of video tutorials taught by experts. Get started

Flex 4.6 and AIR 3.0 New Features for Mobile Apps

Building an ANE file


From:

Flex 4.6 and AIR 3.0 New Features for Mobile Apps

with James Talbot

Video: Building an ANE file

In the last video, we talked about how to create a SWC file, and what we did here is we connected the extension development with the extension consumption. So everything that makes up an extension--the descriptor, the ActionScript code, the native code, and all the resources for each platform--is all assembled into this SWC file. Now what we have to do is we have to take this SWC file and package this up into an ANE file, and the ANE file is what the Flex developer adds to their project, and then they can utilize these ActionScript APIs that we defined in our class and these ActionScript APIs, as you see, if I scroll down here, right, this ActionScript API connects back to the native code through the call function, which is very powerful.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Flex 4.6 and AIR 3.0 New Features for Mobile Apps
1h 49m Intermediate Jan 30, 2012

Viewers: in countries Watching now:

Join James Talbot, as he reviews the new features in Adobe Flex, Flash Builder, and AIR for mobile application developers. This course covers the Spark components for building mobile user interfaces in the Flex SDK, and the AIR support for native extensions, which enable applications to use parts of the host operating systems that were previously unavailable. The course also describes new testing and network monitoring capabilities available with Flash Builder 4.6, and the ability for Android applications to be deployed without relying on a separate runtime.

Topics include:
  • Controlling adaptable tablet layouts
  • Controlling view hierarchy
  • Using 16-bit and 32-bit render modes
  • Using the Date Picker, Scroller, and List components
  • Adding a splash screen to a mobile app
  • Using native extensions for iOS and Android
  • Testing with FlexUnit on Wi-Fi
  • Packaging the application for release
Subjects:
Developer Mobile Apps
Software:
AIR Flash Builder Flex
Author:
James Talbot

Building an ANE file

In the last video, we talked about how to create a SWC file, and what we did here is we connected the extension development with the extension consumption. So everything that makes up an extension--the descriptor, the ActionScript code, the native code, and all the resources for each platform--is all assembled into this SWC file. Now what we have to do is we have to take this SWC file and package this up into an ANE file, and the ANE file is what the Flex developer adds to their project, and then they can utilize these ActionScript APIs that we defined in our class and these ActionScript APIs, as you see, if I scroll down here, right, this ActionScript API connects back to the native code through the call function, which is very powerful.

And again, all of this is hidden from the Flex developer. They can simply just import this, link it to the ANE file, and be able to utilize all of these native extensions. So, very, very powerful. Now to actually create this ANE file, we have to do a bunch of different things. So not only do we have to utilize this SWC file, but we have to utilize the contents of the SWC file. So what I am going to do is I am just going to copy this SWC file to my clipboard, so I am going to say Copy, and then I am going to go to my desktop.

And what I am going to do is I am going to paste the SWC file onto my desktop. So I will just say, Edit > Paste, and I will paste that SWC file onto my Desktop. Now for those of you who are familiar with Java, a SWC file is very, very similar to a JAR file. It's just simply a ZIP-based file that contains a whole bunch of different assets. So what I can do is just a Get Info, and I can rename this to a ZIP file. And I will just say use .zip and I will simply unpack the ZIP file like so, and this will create me a directory of all of the assets inside of this SWC file.

You should see the catalog.xml and the library.swf file. Now, we have to use this library.swf file in order to generate an ANE file. Now the extension packages, when we create these ANE files, we utilize the AIR Developer tool. Now this is a command line tool, and this is available in both the Flex and AIR SDKs. And the AIR Developer tool is the same tool used to package AIR applications for deployment, and the options used to create ANE files are very, very similar.

So again, I'm going to assume that we have all of the resources inside of the same directory. You could place them, for example, in this Vibrate directory. And then you of course have to have the global environmental variable set up, and the process is different for that on Mac and for Windows, so that you can access that AIR Developer tool. I'm not going to cover how to set up the AIR Developer tool, but you can catch that in other lynda.com courses that cover AIR and the Flex SDK.

So now once you have that AIR Developer tool set up, you can just simply go to the command line and browse to the directory where all of your files and resources are. In our case this is the Vibrate directory. So let's take a look at how to actually do that and build an ANE file. Now we have to do this at the command line. And the first thing we do is we type in the command adt and we type in what type of package we want to create, and what type of target. So you can see we just use ane for the target. And then we indicate the name that we want our new ane file to have. In this case, we are calling it MyExtension.ane.

Now next comes the path to the extension-descriptor and to the SWC file that defines the ActionScript API. So this extension-descriptor, if I just go right back to my desktop, you will see this in this case is called catalog.xml. This is our extension-descriptor. Now I would have to take this and rename this back to the SWC file, so let me do that. Okay, and what I will do is I will just Get Info and I'll call this again, a swc. Again I'll say use .swc, so I will just move that SWC to that same directory.

Now you'll see that SWC file is there as well. You'll see, so I am pointing it to that extension-descriptor.xml--in our case, I will just call catalog.xml--and then I'm saying this SWC, and again, this is all assuming everything is in the same directory. You could of course place the paths, if they were not in the same directory. And then I am going to point in to the actual SWC file. Now after this comes one or more sequences which specifies the individual sets of files necessary for each platform.

So for example, if I wanted to support the iOS platform, I would simply specify platform iPhone-ARM, and then I have to indicate the library.swf. And this is the APIs in ActionScript that connect back to the native API. So you have to say library.swf. This is the reserved name. Again, the same implementation in this example is used on both platforms, but you could use different SWF files if you wanted to.

So it still needs to be called library.swf, but it could be different settings. So, for example, here it is on the Mac platform, and I could also of course put in the Android platform. But you can see, again, I'm utilizing the library.swf, I am saying MacOS-x86, and then I am specifying where that is. So now remember, this is a very simple example. We contained only the minimally necessary library.swf in the library and the framework for each target platform, but remember, for the default platform, only library.swf is required.

And remember, in real life you're probably going to have lots of other additional files in that same SWC file. So for example, you might have images, you might have sound files, you might have resource bundles, and so on. And again, we are just utilizing this as a very, very simple example. So again, the root catalog.xml and the library.swf are taken from the specified SWC file. And again, if the swc did contain any other files, such as image or sound files, you would need to add those to the same directory before you build out the ANE file.

So that is the process of how to build an ANE file and how to link it back to your project.

There are currently no FAQs about Flex 4.6 and AIR 3.0 New Features for Mobile Apps.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Flex 4.6 and AIR 3.0 New Features for Mobile Apps.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked