The Extensioncontext in 1.AS3 is its core class, which is responsible for interacting with Java code.
Extensioncontext needs to invoke the Createextensioncontext method to create and initialize native code on the Java side.
Instead, you use the call method to invoke specific Java code and get the result returned. Extension also accepts events thrown from Java code.
The generated jar will be identified in the Extension.xml
2. Local Java Project section
The key interface Freextension is the portal to the Java-side custom code, which, when generated ane, will be set in Extension.xml for this entry class
Key class Frecontext (save "key": Frefunction key-value mapping)
Critical interface Frefunction only one call method needs to be implemented,
3.flash Invoke Java process:
1) Extcontext = Extensioncontext.createextensioncontext (extension_id, ""); extension_id to be consistent with the ID label in Extension.xml
This line of code will allow the freextension in Java to be new, and then frecontext be new, the key value map takes effect
2 Extcontext.call (String)//This string is the key of the key value defined in the Java Frecontext, then the associated frefunction will be new and automatically invoke the Call method
4.java return data to Flash:
1) Flash: Extcontext.addeventlistener (Statusevent.status,onstatushandler);
2 Java: Frecontext.dispatchstatuseventasync ("Code", "level");
3) Onstatushandler (e:statusevent) {E.code on = = "Code", e.level== "level"}
5. Generate ANE Files
Create a new directory as a working directory (anebuild) and create subfolders for it Android-arm
Copy the. swc files and extension.xml that are automatically generated in the Flex Library project to the Anebuild directory
Zip to unzip. swc file to get catalog.xml and library.swf files coexist under Android-arm folder
Copy Anetestnative.jar to Android-arm folder
Copy your own signature file. P12 to the Anebuild folder
Final results
Anebuild:android-arm folders,. swc files, extension.xml,. p12 files
Android-arm:catalog.xml, library.swf, Anetestnative.jar
Use the command prompt to go to the Anebuild file directory and package the above files using the ADT command
[Plain] View plaincopy
"D:developadobeadobe Flash Builder 4.5sdks4.5.0-air3.0binadt"-package-storetype pkcs12-keystore linxcool.p12- Storepass 08002615-target anetest.ane EXTENSION.XML-SWC *.swc-platform android-arm-c.
LINXCOOL.P12: Signature File
08002615: Signature Password
Anetest.ane: Generated ane file name
6. When making ane SWC Note: Flash builder4.6 need to add "-swf-version 13" in the compiler's accompanying parameters or ane invalid file when packaging SWC. The extension NameSpace requires the SWF verison to is or lower
7, if the ANE package, the Android-arm/res folder has this file: Dpay_btn_gray_press.9.png, then Flash Builder issued APK error: AAPT tool Failed:error: The application temp file under C disk can't find the picture!
8. If the Java project Lib has folders, such as Armeabi, then in the packaging ane, also put under Android-armlibs
9.bat Batch processing command learning:
(1) The directory where the current. bat file is obtained: Set root_directory=%~dp0
(2) Output: Echo
(3) Using variables:%root_directory%
The 10.FREFunction call method has only two parameters called (Frecontext arg0, freobject[] arg1), regardless of the number of parameters in Flash, are placed in freobject[] Arg1
Freobject is used to wrap flash objects, return parameters to Flash, and use this type