ADOBE AIR
Monday 25th of February, AIR (Adobe Integrated Runtime), already considered as a top ten technology by Technology Review (The MIT magazine) for offline web applications is send out in the Galaxy.
For more information you can also read the article from the New York Times on the impact of AIR.

If you didn’t started yet with AIR don’t worry! It’s just a single click away for your web applications to be on the desktop. With a few more lines of code you can have rich interaction with the desktop.

Start here.

Or go tonight to your local User Group (tonight in Geneva).

Ahmet

 

February 2008 Special Event
If you missed the news, please don’t forget that we will have our monthly meeting February the 25th at The Nomades.

Notre prochaine séance AUGG se déroulera le lundi 25 février à 18h30 au Nomades (map).

Au programme :

- Une présentation des nouvelles fonctionnalités de Flex 3, par Thierry Bertossa

- Une présentation sur AIR par Cédric Tabin.

- Une vidéo (exclusive pour les User Groups) de Kevin Lynch qui parlera du future des technologies Adobe.

Une pizza et à boire !

Concours : Amener des nouveaux membres à AUGG !

La personnes qui amènera le plus de nouvelles personnes lundi se verra offrir le livre ‘Essential ActionScript 3.0’ de Moock ou, au choix, ‘AJAX Design Pattern’ de Mahemoff. Le livre restant ira pour le 2ième . En cas d’égalité, la personne qui a globalement amené le plus de monde à l’AUGG sera le vainqueur…

RSVP – Tout le monde peut venir, svp, envoyez ce mail aux personnes qui pourraient être intéressées – Pensez à me prévenir si vous venez pour la pizza :)

Plus d’info sur le site de l’AUGG

 

The incredible advantage that Desktop application have on web application is the connection with the local computer (other application, file system, computation, …). Unfortunately the mix between AIR and desktop properties are not as far as Java or C. The most wanted functionalities are to launch native application through AIR and integration with native libraries.
There are not a lot of work around: commandproxy, is aimed to bridge the communication between AIR and .NET.
Another project is Artemis but it was abandoned. Today the project rebirth under the name of Merapi.
Merapi use Java to connect AIR to the desktop. The project will be (unfortunately not yet) distributed as a freeware and then as an open source project on Google Code.
Here you can find information on Merapi and the here about the signification of Merapi.

I wish them a lot of success and I can’t wait to test it :)

Ahmet

 

I just realized how much free content we can get from Google Books. If you don’t have enough money to buy all the books about ActionScript 3.0, why don’t you just read them online?
Make a search for ActionScript 3 on Google Books and you will find some incredible title (not complete but still enough to start).

Here are some books you can start reading right now freely:
Essential ActionScript 3.0
ActionScript 3.0 Cookbook
ActionScript 3.0 Design Pattern
Flash CS3: The Missing Manual

Enjoy your readin :=)

Ahmet

 

URLVariables Class allow you to send or receive data from an URL encoded feed (with the data property of the URLRequest class).
There is so two possible use:

  1. Sending parameters to a server side script
  2. Read parameters written from a server side script

The use is quite simple, let’s start by building the PHP file that will receive the variables from a POST method and echo them again with a list of parameters association by name and value: email=”..”&id=”..”&db=”…”.

< ?php
 $psPreRegEmail=$_POST['sEml'];
 $FRM_ID=$_POST['sID'];
 $psBD=$_POST['sBD'];

 echo "email=".$psPreRegEmail;
 echo "&id=".$FRM_ID;
 echo "&db=".$psBD;
?>

Now we need to prepare our AS3 script that will send this 3 variables to our PHP file:

var request:URLRequest = new URLRequest("http://www.server.com/varsTest.php");
var variables:URLVariables = new URLVariables();//create a variable container
variables.sEml = email;
variables.sID = theForum;
variables.sBD = theDB;
request.data = variables;//add the data to our containers
request.method = URLRequestMethod.POST;//select the method as post
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleComplete);
loader.load(request);//send the request with URLLoader()

Here we send the variables and wait for the Event.COMPLETE, it will indicates us that the php files is totally downloaded (and so all the scripts has been executed). Now we can prepare our HandleComplete function:

function handleComplete(event:Event)
{
var loader:URLLoader = URLLoader(event.target);
var vars:URLVariables = new URLVariables(loader.data);
//Access data from the PHP file
trace("vars.email: "+vars.email);
trace("vars.id: "+vars.id);
trace("vars.db: "+vars.db);
}

That’s all!

Ahmet

 

A while ago, the as3corelib has been published on Google Code with a useful tool: JSON encoder and decoder.

JSON (JavaScript Object Notation) is a lightweight computer data interchange format (that is intended to solve XML structure weight), that allows you to send Object (Array, Strings, Number, …) to your server scripts or to JavaScript.

JSON is commonly used by Yahoo Web Services for example.

To use JSON and URLRequest even faster and simpler, I’ve create a small class that allows you to configure your URLRequest in one line (called PhpInteract), to add variables and to precise if your variables are encoded in JSON.

AS3 example to load a XHTML file:

var mi:PhpInteract = new PhpInteract(); //New object of the PhpInteract Class
mi.loadFile("http://www.w3.org/TR/2008/WD-xhtml-access-20080107/");

Now to get the content of the file just do as usual with the onComplete Listener:

mi.addEventListener(Event.COMPLETE, completeHandler);

public function completeHandler(e:Event):void
	{
		//file is completely loaded
		trace("File Content :\n"+mi.content);
	}

You are certainly thinking that a new Class to do this is completely useless… And I agree. Now we can do something more interesting and pass variables (encoded in JSON) to our server side script:

var arr:Array = new Array("a", "b", "c");//An array for the demo...
mi.loadFile("http://yourserver/fromFlash.php",arr, true);
mi.isJSON = true; //We specify that the content must be JSON encoded

Now for the demo, our below PHP code will decode the received JSON string and will re-encode it in JSON and echo it. Our Flash / Flex / AIR application will be able to decode the content as well and handle complex data from PHP (or any server side languages that can encode and decode JSON).

< ?php
$flash = $_POST['fromFlash'];

$testArray = json_decode($flash);

//We can access to the Array Element
echo "Array [0]".$testArray[0]."\n";
echo "Array [1]".$testArray[1]."\n";
echo "Array [2]".$testArray[2]."\n";

echo json_encode($testArray);
?>

What you need to make it work:
- The as3corelib
- The PhpInteract Class

Below is a complete sample:

package
{
	import flash.display.Sprite;
	import ch.metah.mURL.PhpInteract;
	import flash.events.*;

	public class InitmURL extends Sprite
	{
		var mi:PhpInteract = new PhpInteract();
		public function InitmURL()
		{
			//var arr:Array = new Array("a", "b", "c");//for the demo
			//mi.loadFile("http://metah.ch/seo/fromFlash.php",arr, true);
			//mi.isJSON = true; //is JSON content in loaded file?

			mi.loadFile("http://www.w3.org/TR/2008/WD-xhtml-access-20080107/");

			//USE EventListener
			mi.addEventListener(Event.COMPLETE, completeHandler);
			mi.addEventListener(Event.OPEN, openHandler);
			mi.addEventListener(ProgressEvent.PROGRESS, progressHandler);
			mi.addEventListener(HTTPStatusEvent.HTTP_STATUS, HTTPHandler);
			mi.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
		}

		public function completeHandler(e:Event):void
		{
			//file is completely loaded
			trace("File Content :\n"+mi.content);
		}
		public function openHandler(e:Event):void
		{
			//trace("Download started");
		}
		public function progressHandler(e:ProgressEvent):void
		{
			//Handle Progress
			//trace("Loaded"+mi.bytesLoaded+"Total"+mi.totalBytes);
		}
		public function HTTPHandler(e:HTTPStatusEvent):void
		{
			//trace("HTTP Status:"+mi.httpStatus);
		}
		public function errorHandler(e:SecurityErrorEvent):void
		{
			//Handle Security Error Here
		}

	}
}

Ahmet

 

Great proof of concept released by Mike Chambers on how to create an interaction between C# / .NET and AIR application.

You can have more information on the project home or from Mike’s post.

Ahmet