Intermediary Flex classes

These classes mediate between Flash and Flex and provide some minor translation of the functionality of Flash into the functionality expected by Flex. FlexSprite and FlexShape translate the name property and toString() method into the expected behavior in Flex.

Both classes have essentially the same functionality. In their constructor, they perform an assignment such as this (from FlexSprite):

  1.       name = NameUtil.createUniqueName(this);

The createUniqueName NameUtil class creates a unique name based on the qualified class name of the object is is passed. It appends an incrementing number (stored in a static variable) to the name to ensure uniqueness.

Both FlexSprite and FlexShape trap this assignment in a try..catch block and silently fail if there is an error. This is explained in the comments because DisplayObjects placed on a Timeline cannot have their name property modified.

The toString() method is also overridden (from FlexSprite):

  1.     override public function toString():String
  2.   {
  3.     return NameUtil.displayObjectToString(this);
  4.   }

displayObjectToString in NameUtil loops through all of the DisplayObjectContainer parents of the FlexSprite and prepends them to the string with a dot between each name. It terminates at the Stage instance.

Search Great Flex/Flash Sites