Directly no, it is'nt - indirectly yes, it is. You can set any
instance properties before the constructor is executed, so it can use
them as "parameters". If you want to create the movie clip instance at
authoring time (so placing it manually onto the stage), then convert
it to component (library's right-click menu), specify which properties
do you want to set, and give values in the Parameters panel after
placing an instance onto the stage. However if you create the instance
at run-time, the 4th parameter of attachMovie() is exactly for the
same purposes. And there is another option, if you associate a
MovieClip instance and a custom class at run-time using the prototype
hack (and not in the Linkage settings dialog) - in this case you can
pass parameters to the constructor almost in the normal way (at least
from your class' point-of-view), e.g.:

class MyClass extends MovieClip {
  public function MyClass(parameter1, parameter2) {
    trace(parameter1);
    trace(parameter2);
  }
}


class Application {
  private var objectID: Number = 0;
  
  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;
  }
}

...

var mc: MyClass = Application.attachObject(MyClass, "LinkageID", this, 
getNextHighestDepth(), "value1", "value2");

  Attila

JN> Is it possible to send parameters to the constructor of a class that
JN> extends MovieClip, i.e. when the movie clip that is linked to that class 
JN> is loaded?


_______________________________________________
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