Union Platform : a multiuser environment with actionscript

While there are alternatives to actionscript for doing a multi-user application, Colin Mook and Derek Clayton had teamed up (to form User1.net) to do Union Platform. The platform itself provides alternative languages to develop application with, the most notable feature is one can create multi-user applications with actionscript only. Thats a lot of good news on itself. Well, even a sample server environment is free for 1000 users at one time! Huge! Its called “tryuion.com” and provides a testing ground to test your skills for a multiuser application.
The even bigger news is Union Platform is now on cloud in collaboration with Influxis and its at unioncloud.io. Union Cloud is free till its in Beta, so the time is now to build a multi user application with Union Cloud , the feature list looks awesome.
Happy Flashing


Global Error handler with Flash Player 10.1

With FlashPlayer 10.1 comes the ability to handle all the exceptions at one place, aka, Global Error Handler. This means a SWF can be made so that it does not pop-up usual error message dialogues, we generally see now a days with a lot many sites, if we have a debug version of the player. This simply does not mean we should ignore any errors in code. What does it mean is, we still have another gate to filter out any error messages from our application. There can be situation in a team environment, where someone can missout something and that will throw an error on runtime. Well, without further digging into the cause, lets dig into our point of handling the errors.
There is basically another property now to the “LoaderInfo” and “Loader” object. This property is known as “uncaughtErrorEvents”. The trick is to listen to “UncaughtErrorEvent.UNCAUGHT_ERROR” event on this property of the “LoaderInfo” and “Loader” object and handle it. Further more, if we completely want to supress the error dialogue box from poping out, “preventDefault()” must be called on the error handler.
Jumping to the code, add an event handler to the keyboard event like
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
On its handler try to remove a sprite from the display list,which is not yet present in the display list. The code is as below
private function onKeyDown(e:KeyboardEvent):void
var sp:Sprite = new Sprite();
At this point, if we try and run our swf and press any key on our keyboard, the error dialogue will come up.(Keep in mind, this only happens if we have a debug version of the FlashPlayer)
Well, now this dialogue is very annoying if we are an user.  We can avoid this by handing the error on our GlobalError handler. In the beginning of the application listen for error on the LoderInfo object of the main application.
this.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleGlobalErrors);
Now, on its handler call “preventDefault()” method of the error event.
private function handleGlobalErrors(e:UncaughtErrorEvent):void
//this suppresses the error dialogue
//application specific error handlers goes below

The next scenario is when we will be loading external SWFs into our main application. In this case just listen to the Loader objects “uncaughtErrorEvents” property for “UncaughtErrorEvent.UNCAUGHT_ERROR” event as below
var l:Loader = new Loader();
l.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleGlobalErrors);
l.load(new URLRequest(“myOther.swf”));
Thats all, now we have a Global Error Handler in place.
Note :
1. SWFs made for AVM1 with AS2 or AS1 can not be handled for errors on Global Error handler.
2. Even if the Error is handled in the Global Error Handler, the execution of the script does not continue on the call stack that caused the error.
Happy Flashing :)

Air2 beta2, getting started

Its a long time since Adoeb released AIR2 BETA2,but some how I could not got time to play with it till now. Well, here it goes.
First of all there are a couple of ways, one can get started. One is, if you are still in Flex4 SDK (which comes with the new Flash builder), get the new AIR SDK and over-right the old one with the new AIR part of the SDK. That will make you get started. Else, if you always try to be on the challenging and exciting side of things, then I would suggest, get the last nightly build from the opensource.adobe.com. For this test example,I have taken the Build- ( Today’s build, can you feel the edge ;) ). That way, you do not have to over write anything. Well, it does not seem to work directly out of the box as expected. Still we need to copy-paste the AIR2Beta2 SDK files. Nothing to worry, lets get on to the business of setting up the environment. Once you have your Flex4 sdk ready in one folder and AIR2Beta2 SDK in another folder, its just a matter of copy-paste (over-writing the files). Just copy all the files from the Air2Beta2 folders into FlexSDK folder and over write all the files. Thats all we need now.
Well, thats all set for developing your AIR2 applications, as I am not going in detail of setting the environment variables and path in windows systems. If you think, you need help in setting those, leave me a comment here, and I would be more than happy to help you out in that.
Now you need to get the AIR2 BETA2 Runtime, to test and run your AIR2 applications.

There are some minor but must changes to be made to our code, in order to take advantage of the new SDK and Runtime.
  • If you are altogether new to Flex 4 (Gumbo) SDK, the first change would be the namespace at the begining of the MXML file.
<s:WindowedApplication xmlns:fx=”http://ns.adobe.com/mxml/2009&#8243;
All other changes are with the application descriptor file . Lets go one by one here.
  • Here again, there is a change to the namespace. If you are using AIR2 beta 2, the namespace will look as below
Make sure it ends with “/2.0beta2
  • Well, AIR2 introduces Native Process access. To get the access to native process of operating system, AIR application must be bundled with a native installer, that means it must be a DMG if its MAC else it would be an EXE for windows. To bundle and take advantage of Native Process, one has to put the below optional tag inside the application descriptor file.
This does not mean, you are bound to one profile. One can add multiple profiles inside the “supportedProfiles” tag. For example
<supportedProfiles>extendedDesktop desktop</supportedProfiles>
The important thing here is if “supprtedProfile” is set to “extendedDesktop” and the application is tied to be packaged to an AIR file, it simply will not work. It has to be packaged as a native application,which is the next point of discussion. This makes a nice point to the developer as of accidentally compiling to an AIR file when one needed to compile it to EXE or DMG.
-target native myApp.exe
Thats all if you want to get started with AIR2 and all its new capabilities.
NOTE: After writing of the blogpost, I realised that Adobe has released AIR RC today only. I will keep you updated if there is any change on the RC as to BETA2.
Happy Flashing :)

SWF Desktop Application with SWHX

This happened to me with a search for a good alternative to the commercial counter parts for SWF to EXE tools.I was excited to get “Screenweaver“, which is Opensource. At first I thought there is a learning curve to it, so lets search for any other easier options. But then where, there are a lot of free SWF to EXE tools, no one seemed to be as feature rich as their counter parts as Zinc or SWFkit. Then I got a great link through Twitter reply by Arul Kumaran(Thanks a lot buddy). I went through the link and its pretty good to get started with. Finally I was able to make my own chromeless desktop application with ScreenweaverHX(SWHX) within 3 hrs. I was very happy until I tested my application in different machines.It worked perfectly well in many pcs, but then there came a bug in some pc. While the application was showing to be running in the system by the TaskManager, there was nothing visually present in the screen. I will be digging down to that in my next venture to study Screenweaver.
Overall I had a great experience working with SWHX. Here is a tip for those who will be trying to make a chromeless window application with SWHX, just put the swhx window parameter to be “swhx.Window.WF_TRANSPARENT”.In my case I was using the code below in my HAXE application class
var screenSize = systools.Display.getScreenSize();
var window = new swhx.Window( “samApp”, screenSize.w, screenSize.h, swhx.Window.WF_ALWAYS_ONTOP + swhx.Window.WF_TRANSPARENT + swhx.Window.WF_NO_TASKBAR );

This made my application fullscreen, always on top and transparent bg(Chromeless window).

There is another good opensource product named HippoHX coming up. This seems to sit on top of the original SWHX with some added features.

Happy Flashing

AIR Performance Issue

This came to me as a surprise while developing a current application in Adobe AIR. Let me give you some back ground of the project. This is basically a game management system along with playing of the games. All the games are made in Flash itself. I must admit that the games are not coded according to any standards. These games are just working fine as per the requirements doc of the client.There is no optimisation any where in the game. All the graphics are having groups, alphas, masks and what not effects as well. Plenty of alpha tweens, motion tweens. On top of this, we have codes, which are just at most 2 classes. One is a document class and another class is attached to a movieclip on library(whereever is necessary according to the developer!!). Ok, at this point I was being asked to make a UI for all the games to show up and playable too on the same interface. I had given a choice and I insisted on AIR as of obvious reasons, that we could give a better and personal experience for the user.I was confident as I worked with AIR apps previously(all data driven applications). Well, everybody seemed happy upon the AIR thing as we were working on transparent backgrounds, irregular user Intefaces, fullscreen SWFs with text input facility etc. I never knew I was calling trouble to myself. Once I put everything together and tried to run the games inside the AIR application, it failed. Yeah, it failed. I tried the most better coded game out of all the games in another machine from the same AIR application.The game ran fine. I got some optimism. I went ahead and tested the same game from other machines through the AIR application.But it failed.
Overall I found AIR is still not better suited for SWfs which has got a lot of graphics, sound, animation, alphas, masks and all those stuffs designers play arround regularly. Agin if there are a lot of addchild, removeChild as well, AIR applications does not respond as expected. AIR applications take up a lot of memory even for small SWFs made in Flash IDE.THe same SWF takes 30% CPU running on FLash PLayer, but Once I call the same swf from AIR, it suddenly takes upto 70% CPU.
Hope it helps somebody out there.


When I begun with remoting for Flex, I found an array of options as opposed to AS2.Where in AS2 I only found AMFPHP to be effective as per my project requirements(since I am a PHP guy), in AS3 I found AMFPHP and webORBPHP both good enough. To be true, I am an AMFPHP fellow. But upon client’s terms started with webORB.To my surprise, thats also as good. Well, if we consider the remoting to happen in a variety of backends like dotNET, PHP or JAVA, webORB is the best option as it ports everything and all the interfaces look and feel the same.So thats a big plus. If you want your project backend to move from PHP to dotNET or the reverse, as in my case happened, the only headache is the back-end program. But then its quite a lot in terms of its waight. I mean it takes a lot of space, agreed that it has got a lot of features,but still !!
If we consider only PHP, I still will go with AMFPHP. It has got all the same kind of funtionality as webORBPHP but very light weight. Only thing webORBPHP has now is code generation. Which AMFPHP says ‘TO be done’. For me code generation actually does not help me as I am writing down my own classes except in the beginning while learning the webORB the generated codes help me understanding the framework. Again there is no code generation of “MATE”, only PureMVC and Cairngorm.
As per me, if you donot want to port your remoting into a lot of different things other than PHP, AMFPHP is the way to go. For all other things webORB is good.
I still have to have a look at JAVA remoting some day with Flex Data Service, granite data services etc.Tehre are a lot of things going on JAVA side. Need some more time per day, ohh GOD !!

MATE with experience :)

As promised, I am penning down my experince till now with MATE framework.
To begin with its an awesome framework. It really is, I mean it. The documentation of the framework is as good as the framework itself.The most and vital thing about MATE is, it completely separates the VIEW from CONTROLLER.Loosely coupled means loosely coupled :). Everything starts with an event.
Personally till now while creating my own frameworks or while working with a custom framework of any company I have always seen this as the first lines in the VIEW

function onApplicationInit():void{
this.controller=new ApplicationController(this);

This is just to initialise the controller. Then CONTROLLER takes charge of everything and controlls the VIEW.But the problem with this is my view and controller are tightly coupled. I have to write the same initialisation code on all my views just to initialise its controller !!
Well on MATE, its the EVENT ecosystem. Upon VIEW creation on Flex, Flex has a sweet ‘creationComplete’ event dispatched. Now, we can directly bind this event to any eventhadler or make a custom event at this point and dispatch it. Now MATE’s event Map can bind this event to any event handler on any class. So what I will get is VIEW dispatches one event and MATE gives this event to my CONTROLLER and CONTROLLER then handles the situation. VIEW does not know really from where it is being controlled :) sweet as very sweet.

How MATE works? Its a three step process.
1. Create a view (dispatch EVENT for every thing you need to controll)
2. Create an EventMap (maps each EVENT to an EVENTHANDLER)
3. Create a controller (Which handles the EVENT)

Thats it?!! YEAH, thats it. Cool, is not it?