Write Program code
To write the code for the "Hello World" program, edit the mxml file (airhelloworld. mxml) of the program, locate it in the project navigator view, and open it.
All flex air programs are included in the mxml javaswedapplication tag. It creates a simple window that only contains the title bar and the close button.
Add code
1. Add a title attribute to the javaswedapplication component and assign the attribute "Hello World ":
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Export wedapplication xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" Title = "Hello World">
</MX: Using wedapplication>
2. Add a label component, set the text attribute to "Hello air", and set the alignment mode:
<? XML version = "1.0" encoding = "UTF-8"?> <? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Export wedapplication xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" Title = "Hello World">
<Mx: Label text = "Hello air" horizontalcenter = "0" verticalcenter = "0"/>
</MX: Using wedapplication>
3. Add the following style:
<Mx: style>
Application
{
Background-image :"";
Background-color :"";
Background-Alpha: "0.5 ";
}
</MX: style>
The style will be applied to the entire program, and the window background is a bit gray and transparent.
The complete code is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Export wedapplication xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" Title = "Hello World">
<Mx: style>
Application
{
Background-image :"";
Background-color :"";
Background-Alpha: "0.5 ";
}
</MX: style>
<Mx: Label text = "Hello air" horizontalcenter = "0" verticalcenter = "0"/>
</MX: Using wedapplication>