Archive for January, 2007

Release version API

Monday, January 29th, 2007

I have published a software release version API which allows developers to set valid software release versions for a Flex 2 application. Release versions can be utilized for specifying additional meta data within a Flex application.

The release version API contains a main entry point, ReleaseManager; a Singleton containing a reference to the ResourceBundle instance which comprises each valid release code.

A release is set by specifying a valid release code which is defined as a constant in the ReleaseCodes class as follows:

public static const PRE_ALPHA:String = "SR00PA";
public static const ALPHA_VERSION:String = "SR00AV";
public static const BETA_RELEASE:String = "SR00BR";
public static const RELEASE_CANDIDATE:String = "SR00RC";
public static const GENERAL_AVAILABLITY:String = "SRC00GA";
public static const UNSTABLE:String = "SR00UR";
public static const STABLE:String = "SR00SR"
 

Each release code is mapped to a corresponding value in release.properties as follows:

  • SR00PA=Pre-Alpha: {0}.{1}.{2}
  • SR00AV=Alpha Version: {0}.{1}.{2}
  • SR00BR=Beta Release: {0}.{1}.{2}
  • SR00RC=Release Candidate: {0}.{1}.{2}
  • SR00GA=General Availability Release: {0}.{1}.{2}
  • SR00UR=Unstable Release: {0}.{1}.{2}
  • SR00SR=Stable Release: {0}.{1}.{2}

The tokens in each release code are substituted by the developer according to a projects current release version; major, minor, revision/build.

You can download source as well as view the ASDocs

Label statement in AS3

Thursday, January 25th, 2007

In ActionScript 3 a label statement is used to associate a statement with an identifier which can be referenced by both the break and continue statements to exit a block of code (basically, a label statement is the equivalent of goto in C, and yes, I know what you’re thinking!)

For instance, in a nested loop, a break or continue statement will only break out of the immediate loop and will not skip the entire series of loops (the end of the outer most loop) as one might expect. Labels are used as identifiers for an entire block of code from which a break or continue statement can reference in order to skip the entire series of loops or a specific loop from within a series of nested loops.

An example of how a label statement can be used to break out of an outer loop is as follows:

outerLoop:
for (var i:int = 0; i < 10; i++) {
trace("i : " + i);
innerLoop:
for (var j:int = 0; j < 10; j++) {
if ( j == 5 ) {
break outerLoop;
}
trace("j : " + j);
}
}

// j : 0
// j : 1
// j : 2
// j : 3
// j : 4

A label may also be referenced by a break statement to exit a block statement as follows:

escape: {
trace(0);
trace(1);
break escape;
trace(2);
trace(3);
}
// 0
// 1

Typically, it is rare that you would need to use the label statement, however, in certain situations if it is necessary and can be justified, the label statement provides a convenient way to exit code.

Update to Flex 2 Local / Object Debugger

Saturday, January 20th, 2007

One recommendation I would make to the Engineers at Adobe is that the global trace(); method in Flex 2 become a bit more robust. Just as in previous versions of Flex and Flash the trace method only handles simple types; String, Boolean, Number, int, unit etc.

Flex 1.5 had a really good object debugger available but I have yet to find something similar for Flex 2. So I decided to build my own debugger to handle recursively tracing objects of complex type; Array, Collections, Object etc.

The Flex2LocalDebugger is a simple Object debugger API which uses LocalConnection for tracing objects of both simple and complex types to a debugger console. Flex2LocalDebugger does not provide a logging API, however users could easily extend FlexLocalDebugger to add logging capabilities.

The LocalDebugger console runs in a browser so you can easily switch between your application and the debugger from within the same browser, without the need to to run the debug player. This is useful for when you simply want to trace an object of complex type without running the Debug version of Flash Player.

The main entry point into the FlexLocalDebugger API is the LocalDebugger class. The LocalDebugger class provides methods which allow objects to be sent to the debugger console as well as displayed in an Alert window:

  • trace();
    Checks to see if the object specified is of simple or complex type. If the object is of simple type LocalDebugger will send the object to the debugger console. If the object is of complex type, LocalDebugger will recursively trace the object and all elements of the object to the debugger console.
  • send();
    Allows users to bypass recursive tracing and send an object directly to the console.
  • show();
    Traces an object to an mx.controls.Alert window. Similar to trace, mx.controls.Alert will only trace a String in an Alert window. For ease of use, FlexLocalDebugger handles casting an object to String and displaying the object in an Alert window within the application.
  • allowConnection();
    Terminates / allows all connections to LocalDebugger

The debugger will recursively trace an object of complex type. Each call to LocalDebugger.trace(); prints a [trace-object-root] when tracing a new object. This is the root of the top level object which has been specified as the parameter in a call LocalDebugger.trace();.

To use the Flex2LocalDebugger API in your application, simply right-click on your project and select: properties > Flex Build Path > Library Path > Add SWC. Browse to the location of FlexLocalDebuggerAPI.swc and click ok.

You can download the swc as well as view the documentation for the Flex Local Debugger API.

Flex2LocalDebugger is protected under the MIT Licence.

WebORB for PHP v1.3.2

Thursday, January 18th, 2007

I have been hearing a lot about Weborb for PHP so I decided to check it out for myself. If you are not familiar with Weborb, it is a server based technology that provides a Flex RPC service implementation which exposes remote PHP objects to a Flex client via remoting utilizing AMF3.

WebORB for PHP can be installed in your server root on any web server which supports PHP 5. Weborb for PHP is very easy to use and the documentation is good. I had it installed and got the sample application up and running in about 5 minutes.

Weborb for PHP is similar to AMFPHP in many respects. Both Weborb for PHP and AMFPHP alpha 1.9 provide AMF3 support. Neither requires FDS. All in all they both provide similar solutions, just in different ways.

If you are a Flex developer who builds backends in PHP, or if you are a PHP developer who is interested in developing rich client applications in Flex then Weborb for PHP is definitely worth a try.

You can check out the simple start up tutorial at the Weborb site. You can also check out WebORBPHPRemoteGateway, which is a generic base class I wrote that developers can extend for use in a Weborb for PHP Flex application.