Archive for September, 2007

Adobe Thermo?

Tuesday, September 18th, 2007

So what exactly is Adobe Thermo? Or at least what is this new product from Adobe which has been codenamed “Thermo”? I don’t think anyone outside of Adobe really knows for sure just yet…

Based on what I have read so far “Thermo” appears to be a cool new tool which will allow creative professionals to leverage their existing skills to build RIAs utilizing tools they are comfortable with such as the Adobe Creative Suite product line.

Regardless of the specifics, one thing is for certain - any new tool which builds on the Adobe Flash Platform can only be a good thing for RIA developers specializing in Adobe technologies.

So I guess we will just have to wait for MAX 2007 / Chicago in 2 weeks to find out more.

For more information check out Mark Anders post on Thermo.

Static constant definition utility

Sunday, September 16th, 2007

I recently was working on an application where I needed to verify that certain static constants were defined by a specific class. I have run into similar situations like this before so I decided to write a simple utility which I could reuse.

ConstantDefinitionUtil is an all static class which provides an API for determining if specific constants have been defined by a class.

Additionally, ConstantDefinitionUtil provides a method for retrieving all static constants which have been defined by a class.

The following example demonstrates how ConstantDefinitionUtil can be utilized to determine if the static constant “X” has been defined by ClassA:

package
{
    public class ClassA
    {
        public static const X:int = 1;
        public static const Y:int = 2;
        public static const Z:int = 3;
    }
}

import com.ericfeminella.utils.ConstantDefinitionUtil;

trace( ConstantDefinitionUtil.isDefinedBy("X",ClassA) ); //true
 

ConstantDefinitionUtil.as

ComboBox.prompt

Tuesday, September 11th, 2007

This is one of those little things that you come across from time to time and think to yourself, “man, how did I not come across this before?”.

There has been so many times where I have added an item to a collection in order to display a message to the user. For instance, say you have a ComboBox that displays a list of employees and you want to add a message as the first item, specifying something to the extent of “Select an employee”. Typically, an item would need to be added to the dataProvider of the ComboBox at index 0. Then the issue arises where you will then need to take this item into account when it is selected so that it will be ignored.

Well, like most things in Flex there is an out of the box solution!

The solution is the prompt property which can be utilized to facilitate exactly this sort of thing. I stumbled across this property accidentally while extending ComboBox and viewing the source code. The prompt property simple adds an item to it’s data provider at -1. Since Array indexing begins at zero, this item is ignored and you do not have to take it into account when working with the data provider.

<mx:ComboBox prompt="Select an employee" />

Hope this helps someone down the road.

AS3 HashMap Update

Tuesday, September 11th, 2007

I have updated the HashMap API to provide additional functionality which comes in handy when working with managed key / value pairs.

Additionally, I have also modified the HashMap class from an “is-a” to a “has-a” relationship as the previous version was a derivation of Dictionary, thus exposing the map and consequently causing a security breach in the API. This has been fixed as of this update as the map is now private rather than the object itself.

The original IMap interface I created was modeled loosely after operations which are typical of the Java Map interface. However I have identified additional operations which are useful when working with key / value pairs. These new operations have been implemented in the latest HashMap class and comprise all of the new methods.

Below is a list of the additional methods which have been implemented in the HashMap update:

  1. getValues: Retrieves all of the values assigned to each key in the specified map
  2. reset: Resets all key assignments in the HashMap instance to null
  3. resetAllExcept: Resets all key / values defined in the HashMap to null with the exception of the
    specified key
  4. clearAllExcept: Clears all key / values defined in the HashMap to null with the exception of the specified key

You can view the latest HashMap API source for the IMap interface and HashMap implementation. Each method is accompanied by a detailed example.