Basic types and structures

Commons package is a package dedicated to data representation and manipulation. It also contains utility classes.

Basic types


In comparison with Java Object, the native ActionScript 3 Object class does not provide any real comparison mechanism for complex objects. The notion of identity is very important for the design and correct behaviour of an object-oriented application.

The ActionScript language provides two operators to compare objects:

  • the equality == operator, comparing the contents of addresses in the memory. It works fine for primitive types such as Number or String, but does not for complex objects such as Array or Object.
  • the strict equality === compares the pointers associated to the variables to compare, and checks whether they end up at the same address in the memory.

The commons library provides a simple interface, IBasicObject, providing hashCode and equals methods – just like in Java – to be used when creating objects, value objects in particular. Those methods allow the developer to use a basic type capable of performing “logical equality” comparisons: “for my purposes, these two objects are equivalent”.

This ability is particularly interesting when the objects are provided by back-end services, to be able to compare different copies of the same object, in the logical point-of-view: “is the UserVO instance with identifier 245 the same that the object that resides in my Model, with identifier 245 ?”

The ActionScript Foundry assumes the IBasicObject is the basic type for all value objects and value beans.

Basic implementations


BasicObject class is a general implementation of the IBasicObject interface. It provides basic mechanism to allow object identification and object comparison (hashCode based on instance byte array, equals using the == operator, and getInstanceId). This class should be used as a base class, but we encourage you to override hashCode and equals methods.

ObjectWrapper and ArrayWrapper

Most data structures provided by the ActionScript foundry assumes the IBasicObject type as the base for complex data types. A developer could have – occasionnally – to use classes that are out of the IBasicObject inheritance graph. The Commons library provides two proxy classes, ObjectWrapper and ArrayWrapper, used to wrap objects or arrays. This way those objects can be stored into data structures provided by the commons library.

Data structures

See collections framework for more.


The utilities package contains some tools for data manipulation.

  • Array utilities: contains functions for Array and ArrayCollection manipulation
  • Class utilities: contains some useful functions like adding dates, difference calculation and comparison
  • Date utilities: some useful date manipulation utilities
  • Introspection utilities: find if the class has some inheritance on its tree
  • Serialization utilities: methods for basic types manipulation
  • String utilities: String manipulation tools
  • URL utilities: URL manipulation tools

Previous Step

Next Step

Friday, November 21st, 2008 No Comments by Sylvain Didier