BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Archive for October, 2010

Reading File names inside a folder in Adobe AIR

Posted by Shardul Singh Bartwal on October 31, 2010

Reading the file names(including the folder names) in adobe air is a straight forward task.You have to decide the folder location i.e. desktop,document or application folder etc. And then you can get the file listing of that folder very easily. As I have done for a folder which is on my desktop.Below is code for the same.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="" layout="absolute"
			private function getFolder() : void
				var dir : File = File.desktopDirectory.resolvePath("MyFolder");

			private function onDirectoryListComplete(event : FileListEvent) : void
				var cont : Array = event.files;
				for (var i : uint = 0;i<cont.length;i++)
					trace(cont[i].name + "....." + cont[i].size);

Posted in AIR | 5 Comments »

Moving Adobe AIR Application

Posted by Shardul Singh Bartwal on October 18, 2010

Moving any air application is already provided feature with any air application if you are having title bar with it.
But let suppose you requirement is such that you dont require to show the title window.In that case if you want to
move your window with mouse on the any particular Display object then you can acheive this some thing like this.
Just call two function on that partiuclar display object the one for moving the application and another for stoping this
moving.Like below:-

private function onMouseDown(event : MouseEvent) :void

private function onMouseUp(event : MouseEvent) : void


I am using there this word as I m currently inside the WindowedApplication.

Hope you will enjoy this…….

Posted in AIR | 3 Comments »

Byte Array to BitmapData and BitmapData to Byte array in Flex 3.

Posted by Shardul Singh Bartwal on October 14, 2010

In the code below I am initially getting the byte array of my canvas with the increased size. Converting it into Bitmap data.And again converting that Bitmap data into ByteArray. So that you can use the particular step which one you require.

<?xml version="1.0"?>
<mx:Application xmlns:mx="">

import mx.controls.Alert;


private var imageSnapshot:ImageSnapshot
private function inLargeImage():void
var jPEGEncoder:JPEGEncoder = new JPEGEncoder(90);
imageSnapshot = ImageSnapshot.captureImage(imgCanvas,500, jPEGEncoder,true);

// is ByteArray.

private var loader : Loader = new Loader();
private function byteArrayToBitmapData(byteArray : ByteArray):void
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);
private var bitmapData:BitmapData
private function getBitmapData(e:Event):void {
var content:* = loader.content;
bitmapData = new BitmapData(content.width,content.height,true,0x00000000);

var matrix:Matrix = new Matrix();
bitmapData.draw(content, matrix,null,null,null,true);
targetImage.source = new Bitmap( bitmapData );


private function saveInLargeImage() : void
if(bitmapData == null)
{"InLarge Image first,and then try again.")

var encoder:JPEGEncoder = new JPEGEncoder(90);
var byteArray:ByteArray = encoder.encode(bitmapData);
var fr : FileReference= new FileReference();,'abcd.jpg');


<mx:VBox horizontalAlign="center" verticalAlign="middle" width="100%" height="100%">
<mx:VBox id="imgCanvas" width="600" height="450" horizontalAlign="center"
verticalAlign="middle" backgroundColor="0x0000FF">
<mx:Image source="image1.jpg"/>

<mx:Image id="targetImage"/>

<mx:Button click="inLargeImage()" label="Inlarge Image"/>
<mx:Button label="Save To Your Computer" click="saveInLargeImage()"/>


Hope you will enjoy this……..

Posted in ActionScript 3.0, AIR, Flash Builder 4.6, Flex, Flex 3.0, Flex 4, Uncategorized | Tagged: , , , , , , , , , , , , , , , , , , , , | 2 Comments »

Applying Filter in actionscript 3.0 and Flash CS5

Posted by Shardul Singh Bartwal on October 12, 2010

Applying this is very simple and straight forward.I am having two things on my flash stage.

One is a slider namely ‘hs’ and another one is a movie clip with name ‘rect’.Below is the code for achieving

this.As you will made the change in slider there will be a change in the filter for movie clip.Below is the code.

Please note that I am doing the frame coding so there is stop() at initial.And as I have taken the maximum value for

my Slider hs to ‘100’ and as we know alpha can have maximum value of 1,so i am dividing it by 100.

import fl.controls.Slider;
import flash.filters.GlowFilter;


hs.visible = true;
function onSliderChange(event : SliderEvent) : void
var s : Slider = event.currentTarget as Slider;
var glowArray:Array = [new GlowFilter(0xff0000,s.value/100,4,4,2,1,false,false)];
rect.filters = glowArray;

Enjoy……….Action scripting..

Posted in ActionScript 3.0, Flash CS5 | 1 Comment »

Creating Transparent Application Window in Adobe AIR

Posted by Shardul Singh Bartwal on October 7, 2010

Acheiving this is very simple. You need to made two changes in the YouApplicationName_app.xml by setting systemChrome and transparent properties.


And inside your WindowedApplication you have to set these four properties:-


Thats all and you will achive this.


Posted in AIR | 1 Comment »

Getting Ethernet Adapter(MAC Address in AIR Applicaion)

Posted by Shardul Singh Bartwal on October 3, 2010

Its very simple and easy to get the MAC address of any computer with Adobe AIR application.

With just two to three lines you can find it very easily.Just have a look at lines below
and you will get the MAC address of the computer in which your application is running.

var networkInterface : Object =  NetworkInfo.networkInfo.findInterfaces();
var networkInfo  : Object = networkInterface[0];
var physicalAddress : String = networkInfo.hardwareAddress.toString();

Hope you will like it…………

Enjoy Flexing…….

Posted in AIR 2.0 | 7 Comments »