In the previous section, we talked about how to build the development environment of the Adobe Flash Builder 4.5 Android Air Program Development Series. This section describes the simple HelloWorld program.
Q. Create a HelloWorld Project
First, create the Flex mobile phone project in the development environment of 4.5, select File and Flex mobile phone project, as shown in figure 1.
Figure 1 new mobile phone project
In "Project Life", add the project name "HelloWorld" and select your own directory in "folder. Click Next To Go To platform settings, as shown in figure 2.
Figure 2 platform Selection
Select default, and click Next to enter the configuration server settings window, as shown in 3.
Figure 3 Server Configuration window
Select default and click Next to enter the build path window, as shown in figure 4.
Figure 4 build path window
Click Finish to complete the creation of the Flex mobile phone project.
Q: add the main view of the HelloWorld project.
Add the project content and add code for the main view. The mobile phone project uses multiple practical views, while the program switches between multiple views. The code for HelloWorldView. mxml is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<S: View xmlns: fx = "http://ns.adobe.com/mxml/2009"
Xmlns: s = "library: // ns.adobe.com/flex/spark" title = "homepage View">
<Fx: Script>
<! [CDATA [
Protected function btnShow_clickHandler (event: MouseEvent): void
{
LblShow. text = "HelloWorld ";
}
]>
</Fx: Script>
<Fx: Declarations>
<! -- Place non-visual elements (such as services and value objects) Here -->
</Fx: Declarations>
<S: layout>
<S: VerticalLayout paddingTop = "10"/>
</S: layout>
<S: Label id = "lblShow"/>
<S: Button id = "btnShow" click = "btnShow_clickHandler (event)"/>
</S: View>
A label and a button are displayed on the main interface. After you click the button, the font of the label changes to "HelloWorld". 5.
Figure 5 design view
Q HelloWorld project debugging Configuration
Click debug | debug configuration to go to figure 6.
Figure 6 debugging Configuration
Select "on the desktop" and "Motorola Droid Pro. Click debug to enter the debug status of the project, as shown in figure 7.
Figure 7 HelloWorld debugging status
Q. Install the running environment of the simulator
The simulator must first install the runtime environment to run the Adobe AIR program. Run AIRSDK> runttimes> air> android> emulator> runtime.apk.copy the runtime.apk. File to Android-sdk-path/tools /.
The installation command is Android-sdk-path/tools/adb-e install Runtime.apk. The installation process is shown in figure 8.
After the installation is complete, you can view the effect after the installation in the simulator. [Home] | [Setting] | [Applications] | [Manager applications]
As shown in figure 8.
Q package the HelloWorld project as an apk File
After HelloWorld is compiled, two files are generated under the bin-debug directory,
Set AIR-sdk-path/bin to path, so that you can directly use the adt command. Adt-package-target apk-debug-storetype pkcs12-keystore youceritificate. p12 hello.apk HelloWorld.-app. xml HelloWorldswf. The process is as follows:
After the password is entered, the hello.apk file is generated in the bin-debug directory.
Q. Install HelloWorld to the simulator.
Beihello.apk to Android-sdk-path/tools/, installation command:
Android-sdk-path/tools/adb-e install hello.apk
After the installation is successful, you can find the program in the application.
Source code: