How to Use Adobe AIR to expand ane locally in Windows

Source: Internet
Author: User

The following are my experiences on how to use the native ANE of Adobe AIR in windows.

This article has greatly improved the support for ANE in flashcs5.5 and CS6.

1. official help

Http://help.adobe.com/zh_CN/air/build/index.html

Main reference:

1. Develop local extensions for Adobe AIR

2. Build an Adobe AIR application

Many of the content in this article comes from these two help files.

2. Some ane libraries on the official website

Http://www.adobe.com/devnet/air/native-extensions-for-air.html

I mainly referred to the ICU

Http://blogs.adobe.com/globalization/invoking-icu-from-adobe-air-applications-part-2-using-flash-builder-4-6/

Ii. Role of ANE

1. Local Code implementation provides access to platform-specific functions. These platform-specific functions are not available in the built-in ActionScript class, nor can they be used in the application-specific ActionScript
Class. The local code implementation can provide such features because it can access device-specific hardware and software.

2. The implementation of Local Code may sometimes be faster than the implementation of only ActionScript.

3. Use of ANE

Like the SWC file, the ANE file is also an ActionScript
Class Library, including SWF files in archive format and other resource files. Taking the yt.ane(it is also a zipformat example, the main user needs to package a library.swf file and
Yt. dll file.

The usage method is the same as using the SWC file. I use flash cs5.5 to create an air
Project, enter the following code in the timeline

VaR yt: test1 = new test1 ();

Mytext. Text = yt. Say ();

The following describes the self-built adobeair
Applications

1. Declare the extension in the application descriptor File

All air applications have application descriptor files. When an application uses a local extension, the application descriptor file contains

. For example:

<Extensions>

<Extensionid> test1 </extensionid>

</Extensions>

The value of the extensionid element is the same as that of the ID element in the extension descriptor file. The extension descriptor file is a file named extension. xml packaged in ane
File. You can use the archive Extraction Tool to view the extension. xml file.

2. If the application uses a local extension, please include the ANE file of the local extension in the library path. Then you can use Flash Professional cs5. Perform the following operations:

1. Change the file extension of the ANE file from. ane To. SWC. You must perform this step so that Flash Professional can locate the file.

2. In the FLA file, select "file"> "ActionScript Settings ".

3. In the "advanced ActionScript 3.0 Settings" dialog box, select the "library path" tab.

4. Select the browse to SWC file button.

5. Browse to the SWC file and select "open ".

The SWC file is now displayed on the "library path" tab in the "advanced settings of ActionScript 3.0" dialog box.

6. Select the SWC file, and then select the "set link options for libraries" button.

7. In the "library path project options" dialog box, change "link type" to "external ".

You can use ane after completing the above work.

I use flashcs5.5 to create an air project and enter the following code in the timeline:

VaR yt: test1 = new test1 ();

Mytext. Text = yt. Say ();

Code Description:

Mytext is a dynamic text, and yt. Say is a method of test1.

Yt. Say calls the test method in yt. dll

Test1 class (as3) Code

Package

{

Importflash. Events. eventdispatcher;

Importflash. External. extensioncontext;

Publicclass test1

{

Private Static varcontext: extensioncontext;

Publicfunction test1 ()

{

Super ();

Try

{

Context = extensioncontext. createextensioncontext ("test1 ","");

}

Catch (E: Error)

{

}

}

Publicfunction say (): String

{

Varstr: String =
Context. Call ("test") as string;

Returnstr;

}

}

}

The test method code of yt. dll:

Freobject test (frecontext CTX, void * funcdata, uint32_t argc, freobject argv [])

{

Constuint8_t * MSG = (const uint8_t *) "Hello World ";

Freobjectretobj;

Frenewobjectfromutf8 (strlen (const char *) MSG) + 1, MSG, & retobj );

Returnretobj;

}

The running result is helloworld

3. Ane Packaging

This program cannot be run directly within flash cs.5.5, and must be packaged.

You can create a BAT file for packaging. My packaging statement is as follows. For details, see the official documentation.

"D: \ Program Files \ Adobe flashcs5.5 \ air3.2 \ bin \ ADT"-package-storetype PKCS12-keystore yt. p12-target bundle myapp.exe application.xmlapp.swf-extdir extensionsdir

In this way, all the files are packaged into a folder, and you can click the file to view the effect.

========================================================== ====================

I. Use C
Programming local code (DLL file)

The Code is as follows:

# Include "flashruntimeextensions. H"

# Include <stdio. h>

# Include <stdlib. h>

# Include <string. h>

Extern "C" _ declspec (dllexport) void extinitializer (void ** extdatatoset, frecontextinitializer * ctxinitializertoset,

Frecontextfinalizer * ctxfinalizertoset );

Extern "C" _ declspec (dllexport) void extfinalizer (void * extdata );

Extern "C" _ declspec (dllexport) freobject test (frecontext CTX, void * funcdata, uint32_t argc, freobjectargv []);

Void contextinitializer (void * extdata, constuint8_t * ctxtype, frecontext CTX,

Uint32_t * numfunctionstotest, const frenamedfunction ** functionstoset)

{

* Numfunctionstotest = 1;

Frenamedfunction * func = (frenamedfunction *) malloc (sizeof (frenamedfunction) * 1 );

Func [0]. Name = (const uint8_t *) "test ";

Func [0]. functiondata = NULL;

Func [0]. Function = & test;

* Functionstoset = func;

}

Freobject test (frecontext CTX, void * funcdata, uint32_t argc, freobject argv [])

{

Constuint8_t * MSG = (const uint8_t *) "Hello World ";

Freobjectretobj;

Frenewobjectfromutf8 (strlen (constchar *) MSG) + 1, MSG, & retobj );

Returnretobj;

}

Void contextfinalizer (frecontext CTX ){

Return;

}

_ Declspec (dllexport) voidextinitializer (void ** extdatatoset, frecontextinitializer * ctxinitializertoset,

Frecontextfinalizer * ctxfinalizertoset ){

* Extdatatoset = NULL;

* Ctxinitializertoset = contextinitializer;

* Ctxfinalizertoset = contextfinalizer;

}

_ Declspec (dllexport) voidextfinalizer (void * extdata ){

Return;

}

Edit and generate the yt. dll file

Code comment:

1. "flashruntimeextensions. H" and the corresponding flashruntimeextensions. lib can be obtained in the airsdk directory.

2. for Windows
Device. Provide the library as a DLL file. Set lib/Windows
Library flashextensions. Lib in the directory of the AIR SDK
Dynamic Link to your DLL. In addition, if your local code library uses Microsoft
Link to the multi-thread and static version of the C Runtime Library. To specify a link of this type, use/mt
Compiler Options.

3. For more information, see Official help.

Ii. Build SWC
File

As code

Package

{

/**

*...

* @ Author yt

*/

Importflash. Events. eventdispatcher;

Importflash. External. extensioncontext;

Publicclass test1

{

Privatestatic var context: extensioncontext;

Publicfunction test1 ()

{

Super ();

Try

{

Context = extensioncontext. createextensioncontext ("test1 ","");

}

Catch (E: Error)

{

}

}

Publicfunction say (): String

{

Varstr: String = context. Call ("test") as string;

Returnstr;

}

}

}

Tes1.swc File

3. package it into ane

"D: \ Program Files \ Adobe flashcs5.5 \ air3.2 \ bin \ ADT"-Package
-Target ane yt. Ane yt. XML-SWC test1.swc-platform Windows-x86library.swf yt. DL

1. library.swf can be obtained from test1.swc.

2. Content in yt. xml

<Extensionxmlns = "http://ns.adobe.com/air/extension/3.2">

<ID> test1 </ID>

<Versionnumber> 1.0.0 </versionnumber>

<Platforms>

<Platform name = "Windows-x86">

<Applicationdeployment>

<Nativelibrary> yt. dll </nativelibrary>

<Initializer> extinitializer </initializer>

<Finalizer> extfinalizer </finalizer>

</Applicationdeployment>

</Platform>

</Platforms>

</Extension>

========================================================== ======================================

Use ANE in Flash CS6 (Windows Local extension)

1. Create an air project,

2. Add the ANE File

Menu file ---> ActionScript settings

Add the ANE File


3. Set air

You can select either the installer or the embedded runtime application.

To use ANE in Windows, you must selectExtended Desktop

4. You can test it in Flash cs6.

5. Release directly after testing. You do not need to modify the configuration file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.