Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Building an ANE file

From: Flex 4.6 and AIR 3.0 New Features for Mobile Apps

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.

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.

Show transcript

This video is part of

Image for Flex 4.6 and AIR 3.0 New Features for Mobile Apps
Flex 4.6 and AIR 3.0 New Features for Mobile Apps

21 video lessons · 4211 viewers

James Talbot
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

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.


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.

Join now "Already a member? Log in

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
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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.