Extending Flex’s logging framework to write custom log files

In these days I played with Flex’s logging framework and I extended it to write log messages to files, both plain text .log files and dynamic HTML, CSS formatted and Javascript powered files with the ability to filter message type (debug, error, fatal and so on).

The logging framework is a powerful feature that comes with Flex’s sdk and it’s composed by the classes under mx.logging package, which includes the two “subpackages” mx.logging.errors and mx.logging.target.

Java developers should be already confident whit such framework, because logging api are commonly used in Java programming,  Actionscript /Flash/Flex developers may find this tool a novelty (as I did).

The objective of logging framework is to provide a tool that offers a far better, flexible and centralized way to debug an application than simple use a lot of trace() callings. With Flex’s debugging framework we are able to print and filtering among different types of message based on their severity, such:

  • INFO
  • WARN

We can also print the timestamp of the message and the class it refers to, and finally we can simultaneously print messages to different targets.

Continue reading

My phone is not supported by Flash Lite distributable player :(

dohI was so curious to do some tests that I thought all windows mobile and symbian devices was supported… however, as I can see, only a small number of mobile phones are compatible with Flash Lite distributable player (23), the full list is here: http://labs.adobe.com/wiki/index.php/Distributable_Player:Supported_Devices

I was able to compile a .cab file for my Samsung Omnia and then install and launch my test application, however an error message said me “Flash Lite is not available for this device”…. arrrggh!!! I’m going to buy a second hand Nokia N95 on Ebay, I’m too curious! :))

Adobe Flash Lite 3.1 Distributable Player for Windows Mobile and Symbian!


Today Adobe has announced its last creature: Flash Lite distributable player for Windows Mobile and Symbian (the platforms I predicted). We can now use Adobe Mobile Packager to create standalone player for applications, without affecting the Flash Lite browser plug-in or pre-installed standalone player, if present into the device… so we can distribute executable swf files that user can open and use on their phone. Flash lite 3.1 now supports Flash player 9 features and security has been improved… however the bad and sad part is that it still doesn’t support Actionscript 3 :(

The software can be download from Adobe labs: http://labs.adobe.com/downloads/distributableplayer.html

The official announce from Adobe is here: http://www.adobe.com/aboutadobe/pressroom/pressreleases/200902/021609FlashLiteDistr.html

Furthermore a big context has been launched today: the Flash Lite Developer Challenge http://www.flashlitedeveloperchallenge.com
with 100.000 $ in prizes!

I’m quite excited although my disappoint about the missing AS3 support and I’m going to learn more about this news and experimenting with my device… and maybe participate to the challenge :)

Converting Java to Actionscript… maybe is not so hard (I hope)

After valuate my own realization of a certain library, I opted to try the porting of an already existent one… which is made in Java. This library has a lot of classes and interfaces and the manually translation would be very time-expensive, considering also that it uses a lot of classes and functions which are unavailable in Actionscript 3. Fortunately I found a small and useful AIR application which automatically converts .java files to .as files (the application is here: http://thunderhead.esri.com/readonlyurl/J2AS3.air), this application anyway helps a lot but many extra-work is required to properly convert the classes… for example Actionscript has not the abstract key, variable can’t be market as final and so on, so we have to manually adjust these issues. Another useful stuff I found is an Actionscript library which aim is to provide to AS3 developers the same (more or less) features and power of Java Collection framework, which provide classes like HashMap, ArrayList, LinkedList and so on (the library can be found here: http://code.google.com/p/addicted2flash/). Despite these helps I’m still facing some incompatibility issues… classes/methods AS3 is missing, but implementing them by myself is quite simple. For example I implemented the Java’s System.arraycopy() in 2 minutes, by following the JavaDoc ).

In conclusion Actionscript and Java have a  lot of stuff in common, the syntax and structure is quite the same, except for some issues like abstract classes and methods, multiple methods and constructors declaration (override). The main difference is that Java provides an huge number of Classes that Actionscript doesn’t, however it seems not so hard to translate Java code and implement Java functionality in Actionscript.

I hope I won’t have to deny my words :)

Using bitwise operators with Actionscript to create arguments flags

Among all books I bought (including Java books), I haven’t one which explain in depth and in a clear manner what bitwise operators are and how to use them. Almost all books has at least a page about the argument but none is able to give an exhaustive explanation. So, after searching the net, I found an extreme useful article by Joseph Farrell on gamedev.net (direct link: http://www.gamedev.net/reference/articles/article1563.asp), which explains bitwise operators in C starting from an introduction to Numbers and number system. The article is valid to Actionscript, Java and other languages too. I started to try to understand bitwise operators, after looked to Flex’s Alert class, which can accept several options (different buttons) as an unique argument (flags). This can be accomplished by using the bitwise OR operator |  (a pipe), which “joins” together different constants:

Continue reading