Hi,

I think registerClass is an oldskool AS1 workaround before you could extend classes in AS2...

   Object.registerClass("myLinkageName", MyClassName);

   Applying classes at runtime in AS2..

you may also need to use the apply, etc to cast a MovieClip to an instance of your class, here is one I made earlier to cast a loaded SWF to an instance of Animation class.

myClip.__proto__ = Animation.prototype; //myClip is a MovieClip
   myClip.__constructor__ = Animation;
   myClip.__constructor__.apply(mHolder);
   myClip._lockroot = true;
//You also have to have a "dummy" instance of your class to assign your newly "casted" instance to.
   var dummy:Animation = Animation(myClip);

   //Then you can call methods of the Animation class on that clip...

   dummy.play();
   dummy.specialNonMovieClipFunction();

It's a tricky one to get the hang of, but this has proved rock-solid since I learnt it and has been a godsend for loading in huge timeline animations created by designers / animators when I was just sent a load of assets to "deal with"...

   Glen

Mendelsohn, Michael wrote:
Hi list...

I have a class (pixViewer extends MovieClip) and an empty MovieClip
(linkage:emptyMC, not registered to any class in the linkage dialog).  I
want attached this emptyMC to the stage and I want it to be an instance
of pixViewer.

__proto__ works, but why won't prototype or registerClass?

//works:
var pv:MovieClip = _root.createEmptyMovieClip("pixViewer", 180);
pv.__proto__ = new pixViewer();
pv.onLoad();

/*
Why doesn't this work:
pv.prototype = new pixViewer();
pv.registerClass(pixViewer);
*/


Thanks,
- MM

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



--

Glen Pike
01326 218440
www.glenpike.co.uk <http://www.glenpike.co.uk>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to