Under the strange title of ‘ A long time ago in a galaxy far, far away…’ Ted Patrick has just published a screenshot of the Flex Builder 3 while loading, so two month after the public Flex 3 Beta 3 the Flex team at Adobe finished their work :)

Version 3 build 3.0.194161

Flex 3

I’m afraid that the public will have to wait some more days before downloading it.
Remember that if you are a students you can get the builder for free.

Ahmet

 

As you certainly know, ActionScript 3.0 is based on ECMAScript language. The new edition of ECMAScript is in preparation (ECMA-262 Edition 4) and will most certainly shape the future of ActionScript 4.0.

Colin Moock is going to do a lecture at FITC about these changes. You can access his lectures notes ‘What’s new in ECMAScript 4.0?‘ or access to the ECMAScript documentation page to have more information on it. It’s also a unique way to get the preview of ActionScript future :)

Ahmet

 

Interesting article written by Peleus Uhley for the Adobe Developer Center about creating more secure SWF web applications.
This article will help you set all the security to protect your SWF from threats, for example:

  • Cross-domain privilege escalation
  • Spoofing
  • Malicious data injection
  • Script injection into the browser
  • Insufficient authorization restrictions
  • Unauthorized access to data in transit
  • Unauthorized local data access
  • Cross-site request forgery
  • DNS rebinding

The article ends by a useful ‘auditor checklist’ for controlling dangerous functions.
I warmly advice this article!

Ahmet

 

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