Archive for the ‘Uncategorized’ Category.

Flash Player Version Test

The following code tests for Flash Player version and returns true for 10.1 and greater:

private var fp10_1:Boolean;
private function init():void
{
    trace("Flash Player Version: " + Capabilities.version);
    fp10_1 = isFP10_1();
    trace("fp10.1:"+fp10_1);
} 

private function isFP10_1():Boolean
{
    var va:Array = Capabilities.version.split(" ")[1].toString().split(",");
    if(int(va[0]) > 10) return true;
    if(int(va[0]) < 10) return false;
    if(int(va[1]) > 1) return true;
    if(int(va[1]) < 1) return false;
    return true;
}

MemberDatabase – AIR application (Flex/PureMVC)

This demo illustrates how you can use Flex, PureMVC and Adobe AIR local SQL database to create simple member management system. With the Member Database you can store unlimited number of members, sort any information in the database and export data to xml file.

Sample Files:
MemberDatabase.zip (ZIP, 647 KB)

AIR 2.0 Native Process with Java program

This application demonstrates how to use AIR 2.0 Native Process with Java program. Air application sends String to Java program, Java program reads it and sends back to AIR app. Before packaging the ‘NativeProcessDemo’ application into an AIR file, make sure you have added the following line to application description file <supportedProfiles>extendedDesktop desktop</supportedProfiles>. Next, use command line tool to package an AIR app in a native installer.

Sample Files:
NativeProcessDemo.mxml (MXML, 12 KB),
HelloWorld.java (JAVA, 1 KB)

Related Topics:

Resumable File Downloader – Simple AIR app

This AIR application demonstrates how to download, pause and resume downloads of larger files(mp3, flv, etc) and save to the user’s computer. Big Thanks to Benjamin Dobler for his blog post Resumable Downloads with AIR.

Sample Files:
ResumableDownloader.air (AIR, 524 KB)

Sending messages from server socket to client sockets

In this example i want to show you how to send messages from server socket(AIR app) to client sockets(AIR apps). You can install all 3 applications on the same computer or ServerSocketDemo.air on the server(it could be your mac or pc) and SocketDemo.air on any other computer on your local area network(LAN).

NOTE: You will need AIR 2 BETA – Download the Runtime

Files: ServerSocketDemo.air, SocketDemo.air, SocketDemo2.air
Source Codes: ServerSocketDemo.mxml, SocketDemo.mxml

Custom Pipe Messages

Strongly typed messages are used to communicate between cores in PureMVC MultiCore application with Pipes Utility. Below is a simple example of a custom pipe message class, and a JunctionMediator using the custom message. Message names are defined in the message itself which makes the message handling very easy.

ContactMessage.as

Export Data to Excel File

In this example i want to show you how to write data to Excel file from a Flex application. I use as3xls library and FileReference.save() method in Flash Player 10.

Make async call from Flex/PureMVC application

In this example I want to show you how to make asynchronous call to a web service from Flex/PureMVC application.
You can learn: how to call a web service from Proxy, convert returned xml into “smart VO’s”, notify the rest of the application about new data.

Setting cursor position at the end of a TextInput control

Below code shows you how to set cursor position at the end of a TextInput control in Flex 4.

import mx.events.FlexEvent;

// Flex 4
private function creationComplete(event:FlexEvent):void
{
    textInput.selectRange(textInput.text.length, textInput.text.length);
    textInput.setFocus();
}

RoundButtonSkin

I have created round button skin for spark button component. RoundButtonSkin has the same shadow, fill, fill lowlight, fill highlight and the border color as ButtonSkin provided by Adobe. A major difference between my skin and Adobe’s skin is that RoundButtonSkin has a different shape – Ellipse.

Feel free to use it in your projects.