DB> it changes the class prototype but errors when i try to initialize the
DB> constructor using the call method.

That's because in this case classes.testClass interpreted by the
compiler in the context of AS2 syntax and not as a simple Function
object. So you have to cast it to type Function directly or through a
variable:

   Function(classes.testClass).call(_root.testMC);

   or
   
   var cl: Function = classes.testClass;
   cl.call(_root.testMC);

Even better to create some static methods for dealing with reclassing
of MovieClips. Here are ones what I'm using in my Application class:

  static private var objectID: Number = 1;

  static public function createObject(aClass: Function, aParent: MovieClip, 
aDepth: Number, aConstructorParams: Array) {
    var result: MovieClip = aParent.createEmptyMovieClip("object" + objectID++, 
aDepth);
    result.__proto__ = aClass.prototype;
    aClass.call(result, aConstructorParams);
    return result;
  }
  
  static public function attachObject(aClass: Function, aLinkageID: String, 
aParent: MovieClip, aDepth: Number, aConstructorParams: Array) {
    var result: MovieClip = aParent.attachMovie(aLinkageID, "object" + 
objectID++, aDepth);
    result.__proto__ = aClass.prototype;
    aClass.call(result, aConstructorParams);
    return result;
  }
  
  static public function castObject(aTarget: MovieClip, aClass: Function, 
aConstructorParams: Array) {
    aTarget.__proto__ = aClass.prototype;
    aClass.call(aTarget, aConstructorParams);
    return result;
  }


   Attila

_______________________________________________
[email protected]
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