Together with "__Packages" you can also use Object.registerClass to bind a
class to a dynamically created movieclip. If used in conjunction with a
static create method you can make creating extended movieclip instances real
easy...

// MyClass.as
class com.misuseit.MyClass extends MovieClip 
{
        public static var LINKAGE_ID:String             =
"__Packages.com.misuseit.MyClass";
        public static var SYMBOL_OWNER:Function         = MyClass;
        public static var SYMBOL_LINKED:Boolean         =
Object.registerClass( LINKAGE_ID, SYMBOL_OWNER );
        
        private static var $nextId:Number               = 0;     
             
        public static function create( parent:MovieClip, name:String,
depth:Number, init:Object ) :MyClass
        {
                var mc:MovieClip;
                name    = name || "MyClass" + ( $nextId++ );
                depth = depth || parent.getNextHighestDepth();
                mc      = parent.attachMovie( LINKAGE_ID, name, depth, init
);
                return MyClass( mc );
        }
} 

// To instantiate on a timeline
var myClip:MovieClip;
myClip = MyClass.create( this );

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas
Sent: 18 March 2007 10:24
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Object.registerClass ...

Stephen.
  Object.registerClass is used all the time in AS2 to connect library
objects to implementing classes - so it's definitely relevant.

Essentially, you use Object.registerClass to tell the system what type of
class should be associated with a clip when it is attached via
attachMovie(). It's the same as specifying the linkage in the linkage
dialog, but is done dynamically in the code (and therefore it's possible to
attach the same symbol as different classes, if you need to - it's also
handy if your library is supplied by a graphic designer who isn't informed
enough to insert the appropriate linkages.)

HTH,
   Ian

On 3/18/07, Stephen Ford <[EMAIL PROTECTED]> wrote:
> Is Object.registerClass no longer relevant when using AS2 and OOP
structure.I understand AS2 class structure, inheritance, etc but am trying
to understand how it was done in AS1 and if I need to know any of the
techniques used before AS2.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to