Flash "/>

Extending the Macromedia V2 Components

22 February 2006 at 7:18 pm

Lesson learned: When extending the V2 components, it is not enough just to construct the new class using the “extends” keyword like this:

class my.Components.MyDataGrid extends DataGrid
{
  function MyDataGrid()
  {
    trace("MyDataGrid instance created with scope "+this);
  }
}

To successfully extend the components you will need two things. One is a set of static variables that the component structure requires. The other is some exported symbols that will be referenced in the variables.

class my.Components.MyDataGrid extends DataGrid
{
  static var symbolOwner : Object = MyDataGrid;
  static var symbolName : String = "MyDataGrid";
  function MyDataGrid()
  {
    trace("MyDataGrid instance created with scope "+this);
  }
}

“symbolName” must be the same as the export ID in your library.
“symbolOwner” should be the base name of your class.

Next, create a FLA containing the component we’re extending (DataGrid) and an empty movieClip with the identifier (Export ID) specified in “symbolName”. The symbol should also link to the AS2 class using full path: my.Components.MyDataGrid. If you’re using FlashDevelop, just add the exported SWF and select “Add to Library”.

Now your extended class is ready to do it’s job. Just add any methods you want to over-ride or any additional functionality required.