Access Client Machine from AIR on Ease

September 14, 2009

This is a dream come true.
To run an EXE from AIR, do the following steps:
Step 1:
Install the exe from this Link
Step 2:
Import Flex Project samples, from install dir ex: C:\Program Files\FluorineFx Aperture\Samples
Step 3:
Copy *.dll files (apimaging.dll,apoutlook.dll,apSystem.dll,fluorinepp.dll and msi.dll) to your Flex src directory
Step 4:
Copy your ‘-app.xml’ to ‘C:\Program Files\FluorineFx Aperture\Debug’ location of install dir for debugging or just pack the AIR


Flex@Beach

July 29, 2009

Flex@Beach is being hosted at Chennai on August 8th.
Check the below links:
Agenda Venue @flexatbeach

The Group link to share files and discussions.
The Videos link live on YouTube.


Loading Image / Swf in MAC, AIR

July 2, 2009

A Quick tip, was stuck today to load an local image / swf inside AIR at MAC OS.
The below is the solution:

var filenotion:String =”;
if(Capabilities.os.search(“Mac”) >= 0) filenotion = “file://”;
Image.source= filenotion +imgFileURI;


Using / Creating Locale for your language

June 24, 2009

How to do :

1 ) To create resource bundles for different languages and then use the ResourceManager class provided by the Flex API to get the resources.
Just changing the locale of the resource manager will reflect changes in the entire application with the values from the new locale’s resource bundle.

How to Create Locale :

For example if I want to support two locales (en_US and fr_FR) in your application and I my parent folder is named as “Locales”, then I might have following folders. As en_US ,fr_FR

It will be like this :
Locales/en_US , Locales/fr_FR

Steps to do before make the Bundle

Part 1 : SDK

Create folder
1 D:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\frameworks\projects\framework\bundles \fr_FR
2 D:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\frameworks\projects\framework\bundles\fr_FR \src

Download and paste
3.http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/framework/bundles/fr_FR inside step 2

Create folder :
4 D:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\frameworks\locale \fr_FR

Execute
5. D:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0

bin\compc -locale=fr_FR -source-path+=frameworks/projects/framework/bundles/fr_FR/src -include-resource-bundles=collections,containers,controls,core,effects,formatters,logging,SharedResources,skins,states,styles,utils,validators -output=frameworks/locale/fr_FR/framework_rb.swc

Part 2 : Project

1. Set System PATH
D:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\bin
2. create required properties file mainBundle.properties
3. keep that file inside a folder with your locale name ‘fr_FR
4.execute from root path
mxmlc -locale=fr_FR -source-path={locale} -include-resource-bundles=mainBundle,collections,containers,controls,core,effects,skins,styles -output=src/Resources_fr_FR.swf

mxmlc -locale=en_US -source-path={locale} -include-resource-bundles=mainBundle,collections,containers,controls,core,effects,skins,styles -output=src/Resources_en_US.swf

After that place that swf file your Project

Locale/en_US :
Inside we need create the file name like “mainBundle.properties” inside that we need to create like that

welcome_title_text=Welcome,
form_first_name_text=First Name
form_second_name_text=Last Name
form_gender_text=Gender
form_gender_list_male_text=Male
form_gender_list_female_text=Female

Locale/fr_FR :
Inside we need create the file name like “mainBundle.properties” inside that we need to create like that

welcome_title_text=Bienvenue ,
form_first_name_text=Prénom
form_second_name_text=Nom de famille
form_gender_text=Sexe
form_gender_list_male_text=Mâle
form_gender_list_female_text=Femelle

Adding Locales to your Projects
Add the locale to the compiler options.
-locale=en_US,fr_FR

This link, claims to have compiled swc files for most languages : Babel


Flex with Java Collaborative using the Best Architectures of Both

June 18, 2009

This Post was my overdue subject, I wanted to help with a sample Application using Cairngorm, Spring BlazeDS Integration & Generic DAO.

This might be a heavy subject as it deals with many subjects:

The Source is available at the link: cairnspring

How to use the source effectively?
it is simple, steps below:

  1. Download, Source and Libs
  2. Unzip both and import “CairnSpring”, to your Eclipse
  3. Paste the lib files to “CairnSpring\WebContent\WEB-INF\lib” folder
  4. Import the “db.sql” into your MySQL Db, (change mysql port to 3036, else can be configured to default in “CairnSpring\WebContent\WEB-INF\config\jdbc.properties” file)
  5. In Eclipse, Window -> Preferences -> Web and XML -> XML Catalog -> Add User Specified Entries with below values
    Location : CairnSpring/WebContent/WEB-INF/config/spring-flex-1.0.xsd
    KeyType : Namespace Name
    Key : http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
  6. Start the Tomcat Server with CairnSpring instance (the server host and port can be configured in file “CairnSpring\flex_src\Server.properties”)

SQLLite DBManager for AIR

April 2, 2009

The code file contains functions for managing SQL Lite Table and Database


fileReference.load()

March 28, 2009

Today, i faced a weird problem of fileReference.load() not working in AIR. Even, in the latest 3.3 SDK. To resolve that, you have to install Flex Builder Update. Then, modify your App.xml into air version 1.5. As, to get the benefits of latest AIR Version.

Otherwise, in AIR: Code gets compiled but when we select a file from system, it throws a error.


Licensing Flex / AIR Application

January 20, 2009

I have came through the thread and this is my solution  to protect the product with a serial key uncrackable.

The solution can be used in both Online browser based / AIR products.

The MD5 class does create a Unique system ID and verifies the MD5 checksum with a foreign key to check whether the user is registered or not.

MD5.registereduser – Boolean returns true, if user is registered.
MD5.skey                      - The Serial key to be used, to register (can store in a db or xml)
MD5.setRegKey(MD5.skey);   – To unlock the product.


Welcome the user with his name

September 22, 2008

Guessing the end-user name, for AIR Applications.
;)
var nameStr:String = File.userDirectory.name;


String converted to Component Dynamically

July 17, 2008

VBox(or any class with package path)

var ctrl:String = ‘VBox’;
var ClassReference:Class = getDefinitionByName(“mx.controls.” + ctrl) as Class;
var ctrlObj:Object  = new ClassReference();

ctrlObj is now the class of any component you need for dynamic usage


Executing exe using Flex (socket)

July 9, 2008

Update Post, only for Windows

Java socket code:

import java.io.*;
import java.net.*;

class SimpleServer
{
private static SimpleServer server;
ServerSocket socket;
Socket incoming;
BufferedReader readerIn;
PrintStream printOut;
public static void main(String[] args)
{
int port = Integer.parseInt(args[0]);
server = new SimpleServer(port);
}
private SimpleServer(int port)
{
System.out.println(“>> Starting SimpleServer”);
try
{
socket = new ServerSocket(port);
for( ;; )
{
incoming = socket.accept();
readerIn = new BufferedReader(new InputStreamReader(incoming.getInputStream()));
printOut = new PrintStream(incoming.getOutputStream());
Runtime.getRuntime().exec(“notepad.exe”);
incoming.close();
}
}
catch (Exception e)
{
//System.out.println(e);
}
}
}

The AIR connects to socket using XMLsockets.
AIR code:

<mx:WindowedApplication xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”><mx:Script>

<![CDATA[
import flash.net.XMLSocket;
var xmlsock:XMLSocket;

public function sendServer():void{

xmlsock = new XMLSocket();

xmlsock.connect("127.0.0.1",3244);
xmlsock.send("call\n");

}

]]></mx:Script>

<mx:Button label=”Click” click=”{sendServer()}” />
</mx:WindowedApplication>

JavaScript code (using external Interface):

function loadexe() {
w = new ActiveXObject(“WScript.Shell”);
w.run(’shutdown.exe /r’);
return true;

PHP Socket code:

<?php
$host = “192.168.1.10″;
$port = 2222;
error_reporting(1);
ini_set(‘display_errors’, ‘1′);
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$max_clients = 1000;
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
socket_bind($socket, $host, $port);
socket_listen($socket, $max_clients);
$clients = array(‘0′ => array(’socket’ => $socket));
while(TRUE)
{
$read[0] = $socket;
for($i=1; $i<count($clients)+1; ++$i)
{
if($clients[$i] != NULL)
{
$read[$i+1] = $clients[$i]['socket'];
}
}
$ready = socket_select($read, $write = NULL, $except = NULL, $tv_sec = NULL);
if(in_array($socket, $read))
{
for($i=1; $i < $max_clients+1; ++$i)
{
if(!isset($clients[$i]))
{
$clients[$i]['socket'] = socket_accept($socket);
socket_getpeername($clients[$i]['socket'],$ip);
$clients[$i]['ipaddy'] = $ip;
socket_write($clients[$i]['socket'], ‘Welcome to Command Socket Server’.”\r\n”);
socket_write($clients[$i]['socket'], ‘————————————————’.”\r\n\n”);
socket_write($clients[$i]['socket'], ‘To Run Command: arguments.’.”\r\n”);
socket_write($clients[$i]['socket'], ‘To Run Windows Command: win arguments.’.”\r\n”);
socket_write($clients[$i]['socket'], ‘To Chat with others: say arguments.’.”\r\n”);
socket_write($clients[$i]['socket'], ‘To Exit: exit.’.”\r\n\n”);
socket_write($clients[$i]['socket'], ‘There are ‘.(count($clients) – 1).’ users(s) connected to this server.’.”\r\n”);
socket_write($clients[$i]['socket'], ‘————————————————’.”\r\n”);
socket_write($clients[$i]['socket'], ‘Enter your command to execute.’.”\r\n”);
echo ‘New client connected: ‘ . $clients[$i]['ipaddy'] .’ ‘;
break;
}
elseif($i == $max_clients – 1)
{
echo ‘Too many Clients connected!’.”\r\n”;
}
if($ready < 1)
{
continue;
}
}
}
for($i=1; $i<$max_clients+1; ++$i)
{
if(in_array($clients[$i]['socket'], $read))
{
$data = @socket_read($clients[$i]['socket'], 1024, PHP_NORMAL_READ);
if($data === FALSE)
{
unset($clients[$i]);
echo ‘Client disconnected!’,”\r\n”;
continue;
}
$data = trim($data);
if(!empty($data))
{
$pos = strpos($data,’say ‘);
if($data == ‘exit’)
{
socket_write($clients[$i]['socket'], ‘Thanks for using, goodbye.’.”\n”);
echo ‘Client ‘,$i,’ is exiting.’,”\n”;
unset($clients[$i]);
continue;
}
elseif($pos === false){
if(stristr($data, ‘win’) === FALSE) {
$output = exec($data);
}else{
$WshShell = new COM(“WScript.Shell”);
$oExec = $WshShell->Run(substr(stristr($data, ‘ ‘),1),0,true); // not a better option
}
}
else{
for($j=1; $j<$max_clients+1; ++$j)
{
if(isset($clients[$j]['socket']))
{
if(($clients[$j]['socket'] != $clients[$i]['socket']) && ($clients[$j]['socket'] != $socket))
{
echo($clients[$i]['ipaddy'] . ‘ is sending a message!’.”\r\n”);
socket_write($clients[$j]['socket'], ‘[' . $clients[$i]['ipaddy'] . ‘] ‘ . $data . “\r\n”);
}
}
}
}
}
}
}
}
?>


AIR Popup

April 11, 2008

Click here to have a look on AIR with multiple nativewindow instance (App also plays my Marriage video)


Flexible MXML Editor

April 9, 2008

click here for AIR version of Flexible, for editing and modifying the MXML. Alternative for Flex Builder. This works as MXML Parser. I have plans to create SWF instead of mxml (on runtime).


Applying Dynamic Properties for controls

March 19, 2008

Instead of using AS3 dynamic Class for assigning dynamic properties to the DisplayObject, the below line is best alternative:

DisplayObject['property']= value

Using this i am working on mxml parser, planning for swf generator from AIR


PNR Status (Indian Railway)

March 13, 2008

click here to install an Application to check the passenger status for Indian Railway Ticket.


Googler

March 7, 2008

click here to install AIR Application to google ( created using HTML and AIR )


SMTP Quick Emailer – AIR

March 6, 2008

request here to install AIR package using socket to send email using SMTP connection, you can send quick email to any email ID you need, For Source files check this link

  


Adobe Share AIR

March 5, 2008

Click here to use the Adobe Share AIR package for latest AIR version (1.0), using Adobe Share API