Tag Archives: Adobe AIR

Adobe AIR

How to add sprite to a body in Box2D in Adobe AIR, FLEX and FLASH? Or Add image/Sprite to a body in ActionScript.

By | April 12, 2012

The below code is for FlashBuilder 4, If you are using FlexBuilder3 use addChild() instead of the commented block in the following code.

Using ButtonBar in Adobe AIR/FLEX, A simple Example

By | March 1, 2011

Hello………. A button Bar is a convenient way to place your buttons in an application. It saves a lots of space in your application interface. Take a look at the following example which shows how to use the ButtonBar. An itemClickEvent is attached to each button in the ButtonBar. You can place as many buttons… Read More »

Toggle between Full Screen and normal Screen in Adobe AIR or FLEX.

By | February 27, 2011

Hi all……… We often need to toggle between fullscreen and normal screen in our application. The following code snippet helps you to toggle between these two screens in Adobe AIR or Flex. Here I am using StageDisplayState class to do both which has “stage.displayState = StageDisplayState.FULL_SCREEN” and ” stage.displayState = StageDisplayState.NORMAL” constants to do this.

Create PopUp Window in Adobe AIR / FLEX, A simple Example.

By | February 23, 2011

Below code shows how to create a new popUp window in Adobe AIR or FLEX. To create a new window “right click on the src folder and create a new MXML Component named Here “MyLoginForm” It should be aTitleWindow for the example below. How ever You can create other components, but the code accordingly must… Read More »

FullScreen Event in Adobe AIR or FLEX

By | February 22, 2011

  The following simple code snippet explains how to get an eventListener for FullScreen Event in Adobe AIR or FLEX. The function “onScreenModeChange ” gets called when you maximizes your window. private function init():void { stage.addEventListener( FullScreenEvent.FULL_SCREEN, onEnteringFullScreenMode); } private function onEnteringFullScreenMode( e:FullScreenEvent ):void { if( e.fullScreen ) { // Do something on fullscreen…………… } else… Read More »

How to dynamically add controls in Adobe AIR or Flex?

By | February 14, 2011

Below example shows how to add a label control dynamically in AIR or FLEX. var L : Label = new Label(); L.addEventListener(MouseEvent.CLICK,LabelListener); L.name = “my_label_name”; L.text = “my Text”; addChild(L); // This function listens to the mouse click in the above added label. private function LabelListener(event:MouseEvent):void { } Please note that you can add any… Read More »

Access a remote database from Adobe AIR or FLEX.

By | February 8, 2011

Access a remote database from Adobe AIR or FLEX. Many often you need to access online database from your application. For doing it in Adobe AIR of FLEX you need HttpService. The following example shows how to access an online database from an AIR Application. Note that you cannot return an array from a remote… Read More »

Crop an Image in Adobe AIR or Flex.

By | February 7, 2011

Below code shows how to crop an image in Adobe AIR. Change the mx:WindowedApplication to mx: Application to run it as a FLEX Application. The code uses copyPixels to extract the desired part from the image file. The important line in the below code crops the image. cropBD.copyPixels(loadBD, new Rectangle(startPoint.x, startPoint.y, squareSize, squareSize),posPoint);

Dynamically change the background of a window in Adobe AIR?

By | February 6, 2011

Change the background of your window with your selected image. Copy and paste the following code to your AIR file and view the result. Note: Please make sure that you have an image in your application source folder. Here the image name is “image.jpg” else you will get URL not found error.

Pass a variable from one window to another in Adobe AIR?

By | February 6, 2011

We often need to access another window variable in the current window. The following example shows how to access a variable from one window in the next window. The logic is to create an object of next window in the current window and assign the value of variable in the current window itself so that… Read More »

Create a polygon in Flash or Adobe AIR using Box2D.

By | February 5, 2011

The below function creates a polygon in the shape of a triangle. Please call the debugdraw function inside your update method to view the results. Make sure you import the Box2D classes into your file. public function init():void { debug_draw(); addEventListener(Event.ENTER_FRAME, update); createTriangle(); } public function createTriangle():void { var fd : b2FixtureDef = new b2FixtureDef();… Read More »

How to Implement Box2D in Adobe AIR?

By | February 4, 2011

Everyone will be fascinated how flash games are built on the web that implements the real world physics. Well for your information there are a lot of physics engines available. One of them is the Box2D. Box2D was written in C++. Then it was converted to flash. So now I am going to show you… Read More »

How to read and write an XML file in Adobe AIR or Flex?

By | January 15, 2011

AIR treats the XML files as just as normal file and so you can proceed using the FileStream classs. Please take a look at the sample code. Just copy and paste the following code to your main.MXML file and you are done. Please post your comments on this post

Add Context menu in Adobe AIR or FLEX.

By | January 15, 2011

This sample shows how to add a menu to your context menu or the right click of your menu in Adobe AIR. AIR Uses the ContextMenu class to add menu to your mouse right click. import flash.events.ContextMenuEvent; import mx.controls.Alert; // call this function to create context menu in AIR and FLex private function createContextMenu():void {… Read More »