You are viewing the Articles published in

IPV4 Inspector API

I recently had to write a component for an application which allows users to inspect an IP address in detail as well as validate the address against various different criteria. I couldn’t find an API which provides this type of functionality in any of the Adobe classes so I wrote my own. I figured someone else may need to do something similar at some point so I am publishing the API under the MIT License.

The IPV4 API allows detailed inspection of an IP version 4 address (IPv4). It provides a robust API which is not available from Adobe at the moment. Usage is simple and straight forward and contains methods which perform the following:

  • Determine if the address specified is a valid IP address
  • Determine the network class of the specified IP Address
  • Determine the network octet of the specified IP Address
  • Determine the host octet of the specified IP Address
  • Determine if the IP Address is valid for Network assignment
  • Determine if the IP Address is within the Class range specified
  • Determine if the IP Address is a loopback address.

Below is a simple usage example which performs various operations on a specific IP Address:

The IPV4 inspector API can be used for inspecting and validating an IP Address. I plan on adding an update which contains methods for dealing with masks and prefix notation as well.

You can view the ASDoc as well as download the source swc

AS3 Iterator Factory API for Flex 2

I have been posting updates of my utils package lately but haven’t had the time to walk through how to use the API’s in detail other than the provided ASDoc.

One of the really useful API’s in the utils package is the Iterator implementation. The Iterator API provides a standard implementation of the Iterator pattern and is useful for traversing an object, array or collection of objects. The Iterator API provides an Array Iterator, ArrayCollection Iterator and an Object Iterator. You can use them individually as needed but one of the coolest features is the Iterator Factory. The Iterator Factory handles iterator instantiation and allows a single iterator instance, typed as an IIterator interface, to use any of the iterators, via the Iterator Factory.

You can click here to view an example of how to use the Iterator Factory.

AS3 Utility classes available for Flex 2

I have compiled some common AS3 utility APIs for public use as specified under the MIT license.

The utilities APIs are comprised of the following:

Creates a Deep Copy of an object reference to a new memory address and returns the cloned object

Creates a HashMap of object key / values as well as provides a standard API for working with a HashMap

Provides an API for collection alpha / numerical, ascending / descending sorting

Provides a robust API which performs detailed object introspection on a specified type

Factory Pattern implementation which provides an API for Iterator instantiation

Iterator implementation which provides methods for iterating over an object

Iterator implementation which provides methods for iterating over a Collection

Iterator implementation which provides methods for iterating over an array

All static class which extends mx.utils.StringUtil to add additional methods for working with Strings

All static class which returns the current memory allocated to a Flash Player instance in bytes, kilobytes or megabytes

I will continue to add to the utils package and make the updates regularly available. You can download the swc as well as view the ASDoc

AS3 HashMap for Flex 2

The inclusion of the Dictionary class in ActionScript 3 creates numerous possibilities when sub classing. The Dictionary class allows for creating key / value mappings or tables which are more commonly known as Hashes or Hash Maps. The only problem is that the Dictionary class does not provide an API for working with the map. The Dictionary class is a good starting point in which sub classes can create managed key / value hash maps and provide methods for retrieving values and keys as well as removing values, determining how many key / values exist and so on.

I am working on a project in which the data set is comprised of sentences tokenized into their individual parts of speech; noun, verb, preposition etc. Part of the requirement is that a lookup can be made on any individual part of speech to retrieve further information such as tense, plurality and so on. At first I simply used a Dictionary for the mappings but ended up adding all kinds of logic outside of the map whenever I needed to check for a key or add a value and so on. So I decided to write a simple HashMap class for AS3 which is similar to the HashMap available in java.util.HashMap.

Below is an example of how to use the HashMap class:

You can view the source for the HashMap class as well as the IMap interface which defines the methods necessary for working with the HashMap.

One of the good things about Enterra Solutions is that we are partners with Adobe, and through this partnership we get alot of useful tips from the our client engagement partners at Adobe consulting.

I was informed of, a really useful site which alot of people don’t know about. is a site dedicated to providing documentation and learning resources for the Cairngorm Microarchitecture for Adobe Flex. I am a strong advocate of the Cairngorm micro-architecture so if you are a Flex developer new to Cairngrom you should definitely check this site out.

I will also be posting a new tutorial called “Cairngorm made simple!”, which is intended to be a simple “Hello World” application which walks you through the sequence of events in a Cairngorm application. So if you are a bit confused about Cairngorm and how it is implemented, I guarantee that after reading this short tutorial you will have a very clear understanding of Cairngorm, what it does, what it doesn’t do and how to implement Cairngorm step-by-step in an application. So stay posted.

Cairngorm 2.1 Released

Adobe has released Cairngorm 2.1, which is received with a warm welcome on my part. In this latest release of Cairngorm Adobe has deprecated many of the core interfaces that were an integral part of Cairngorm 2.0. The deprecated interfaces are still available in Cairngorm 2.1, however they now extend the interfaces which replace them, so should you choose to upgrade to version 2.1 your exisiting Cairngorm applications should not degrade. The only exception being the Responder interface which is still provided but officially deprecated. Additionally, Adobe has added some new core Cairngorm classes and interfaces which are better suited towards building RIA’s with Cairngorm in Flex 2.0.

The first addition that you will notice is the CairngormError class which is used to throw errors specific to a Cairngorm Application. A Cairngorm Error excepts an error code parameter and an additional parameter of arbitrary length. Cairngorm errors also provide a resourceBundle property which returns a read-only instance of the error specific resourceBundle which is be used to localize an application in a single properties file. The properties file is supposedly exactly like a Java-based properties file which contains name-value pairs, However, Flex expects UTF-8 while Java .properties expect Unicode escaped ASCII.

The second addition that you will notice is the CairngormMessageCodes class which contains a list of static constants which represent the codes found in the file mentioned above. The inclusion of the .properties file in Cairngorm 2.1 actually happens to answer a question that came up during a conversation I had today with one of our Java developers regarding utilizing files in ActionScript 3.0, so how’s that for perfect timing.

The Command interface is now deprecated in place of the new ICommand interface which enforces the contract between the Front Controller and concrete command classes and is a direct implementation of the Command Behavioral Pattern.

The Responder interface has been deprecated and replaced with the core mx.rpc.IResponder interface which essentially provides a similar method signature. IResponder result must be implemented with a data parameter of type Object and fault must be implemented with an info parameter of type Object. For instance, the Responder interface in Cairngorm 2.0 contained 2 methods, onResult and onFault, both of which required a single parameter of arbitrary type, whereas the IResponder interface simply contains a result and fault method which except a single Object as a parameter.

The ValueObject interface has been deprecated and replaced with the IValueObject interface, which is essentially the same marker interface containing the I prefix as a best practice.

ServiceLocator has had a major rework. ServiceLocator.getService() has been deprecated and replaced with ServiceLocator.getRemoteObject(string). ServiceLocator.getInvokerService() has been deprecated also. An IServiceLocator interface has been created to support unit testing and there have been additional security methods added to ServiceLocator.

The FrontControler executeCommand() and getCommand() access modifier visiblity have been changed to protected.

All in all it is a pretty significant release and answers a few questions that I have had. I am an advocate of Cairngorm and support it’s development as a micro-architecture for developing enterprise RIA’s in Flex 2.0 and ActionScript 3.0. To learn more about Cairngorm 2.1 click here. You can also download Cairngorm 2.1 here.