coder and technology lover
Davide Zanotti
This user hasn't shared any biographical information
Homepage: http://www.daveoncode.com
Posts by Davide Zanotti
Extending Flex’s logging framework to write custom log files
Feb 23rd
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:
- DEBUG
- ERROR
- FATAL
- 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.
My phone is not supported by Flash Lite distributable player :(
Feb 17th
I 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!
Feb 16th

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)
Feb 12th
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
Feb 8th
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:
Create custom reusable Flex’s components with Actionscript
Jan 28th
I’ve played for a while with Flex’s library and now I’m experimenting my own custom components and I would like to share them and the knowledge necessary to build personal, reusable cool components.
Fundamentally there are two ways to realize custom Flex’s components: one (and the easiest) is to create an MXML file, the second is to create an Actionscript class.
Populate a Flex’s ArrayCollection… a consideration about addItem() performance
Jan 12th
I’m playing with Flex data Providers and actually I’m testing ArrayCollection. There are 3 ways to populate an Array collection:
- Initialize an ArrayCollection and then use its addItem() method (which accepts any Object type)
- Initialize an ArrayCollection, access its “embedded” Array by using the source property (ie: myArrayCollection.source) an then push objects inside this one
- Initialize an Array, populate it and then initialize an ArrayCollection by passing the Array to its constructor (ie: myArrayCollection:ArrayCollection = new ArrayCollection(myPreviousDefinedArray))
Last technique is (as far I saw) absolutely the fastest , I did a test in which I populated a collection with 300,000 objects and it taken about 9 seconds instead of 32 (350% slower) of first one! The second technique is also faster than the first, but the third is better.
So, what I learned is that addItem() should used only to add few items, instead for huge collection should be avoided in favor of the third technique described in order to obtain better performances.
Implementing Array.shuffle() in Actionscript
Jan 8th
One useful thing that Actionscript doesn’t offers is the ability to shuffle an array, however this can be accomplished in a blink of an eye and with very few lines of code. Before to implement my own solution, I looked on the web, but solutions provided by others developers looks too complex and too long to type. What I found was based on a for loop and several line of codes to fill a secondary array with the elements in a new random order. My solution instead is based on a while loop (3 lines of code only):
We should always use Actionscript’s "this" keyword
Jan 7th
I was wondering if to use or not the “new” keyword for classes variables and methods, because it’s not mandatory and in as3 examples is rarely used and when it’s used, is only to avoid name collisions (typically when setting a class property using a given argument), such:
package {
public class MyClass {
private var myVar:uint;
public function MyClass(myVar:uint) {
this.myVar = myVar;
}
}
}
However there are 3 valid reasons to (always) use the “this” keyword:
- Is an excellent way to visually differentiate between static and dynamic variable (static variables can’t use the “this” keyword, otherwise you get a compile error)
- When invoking methods is immediately evident which is the class owner/target of the method itself
- Faster typing and developing thanks to Flex Builder hints (after typing “this.”, I can select all the applicable methods, which is faster and error free than type the entire method name)
MicroBookReview #1: Essential Actionscript 3.0 by Colin Moock (O’REILLY)
Jan 5th
Despite the word “essential”, in this book Colin Moock shows almost everything about Actionscript 3 and he does it in a clear and exhaustive manner.
The book covers several topics from the scratch and teaches not only the foundations but also some best practices and things to avoid, the topics are the following (generalized):
- Packages, classes, interfaces, functions and methods
- Language’s operators, variables, array and loops
- Animations
- Vector and Bitmap graphic
- Events and event handling
- XML (read, create, manipulate)
- Flash security
- OOP concepts (Inheritance, polymorphism and more)
- Garbage collection
- a Flex hint
Recent comments