Posts Tagged ‘AIR’
28
May

All menus  in Air are NativeMenu objects.
Menu items are NativeMenuItem objects.
You can place Submenus within a parent
NativeMenu object.Also you can use event listeners to
associate menu item selection with a function.

To show a sample menu, You can use the following code.

<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.controls.Button; import flash.display.*; import flash.desktop.*; function init() { this.stage.nativeWindow.menu = new NativeMenu(); var menuItem:NativeMenuItem = new NativeMenuItem("File!"); var subMenu:NativeMenu = new NativeMenu(); var btn1:NativeMenuItem = new NativeMenuItem("Open"); btn1.addEventListener(Event.SELECT, itemClicked); subMenu.addItem(btn1); menuItem.submenu = subMenu; stage.nativeWindow.menu.addItem(menuItem); function itemClicked(e) { Alert.show("You Clicked",e.target); //trace("You Selected: ", e.target); } } ]]> </mx:Script> </mx:WindowedApplication>

After executing You can see the result as

, ,

18
May

You can air sdk to compile an AIR application to show an HTML Page. Try the steps given below:

1. Create an HTML File with the following code and saved it as HelloWorld.html:

<html>

<head>

<title>Hello World</title>

</head>

<body>

<b>Hello World</b>

</body>

</html>

2. Created an xml file with the following code and save it as app.xml

<application xmlns=”http://ns.adobe.com/air/application/1.0″>

<id>test.html.HelloWorld</id>

<version>0.1</version>

<filename>HelloWorld</filename>

<initialWindow>

<content>HelloWorld.html</content>

<visible>true</visible>

<width>400</width>

<height>200</height>

</initialWindow>

</application>

3. Save these two files in a new directory. Here I have stored in D:\HelloWorld .

4. Then go to your flex folder using command prompt as shown in the figure given below and type the command:

5. You will get an output as the figure shown below:

Note: You should note the version of adl installed in your PC with the version given in your xml file.

That’s it. You have done!!!

, , , ,

07
May

When the user inputs a name in the textbox and press the search button , the name is appended to the given URL and it is sent.  Then the details of the given name is get displayed in the text area.    The code is given below.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:WindowedApplication xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>

<mx:Script>
<![CDATA[
private var myUrl:String ="http://schogini.co.in/mca/mca2.php?name=";
//private var myUrl:String ="http://";
private function passUrl():void
{ //function for navigating to the url.

var userName : String;
userName = nameInput.text;
// To append the input name to the url
myUrl = myUrl + userName;

var url = new URLRequest(myUrl);
//navigateToURL(url);

//Add event Listener
var loader = new URLLoader();
loader.addEventListener(Event.COMPLETE,loadComplete);

//load the resource
loader.load(url);

//Function that handles the complete loading of the details
function loadComplete():void
{
outputdetails.text = loader.data;

}
}
]]>
</mx:Script>

<mx:Label x=”94″ y=”35″ text=”Name” width=”160″ id=”namelb” fontWeight=”bold” fontSize=”20″ fontFamily=”Georgia”/>
<mx:TextInput x=”208″ y=”35″ id=”nameInput” height=”26″/>
<mx:Button x=”388″ y=”33″ label=”Search” id=”searchbtn” click=”passUrl();” fontSize=”15″/>
<mx:TextArea x=”10″ y=”91″ id=”outputdetails” height=”239″ width=”529″/>
</mx:WindowedApplication>

Output

,