Attila,

Great... this makes sense and helps immensely!

Thanks for all your help,
--Dave



On Feb 5, 2007, at 4:07 PM, [EMAIL PROTECTED] wrote:

Date: Mon, 5 Feb 2007 20:21:55 +0100
From: Rákos Attila <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] Re: extends MovieClip

DC> Truthfully, I've never used the AS 2.0 class in the linkage box--
DC> this may be what I was looking for!

The simplest way is to assing a class to a movie clip symbol. It makes
each instance of that symbol (both placed on stage at design time or
created at run-time) associated with the given class.

DC> Can this be set up so that instances can then pass parameters to the
DC> class's constructor?

No, you cannot pass parameters directly to the constructor by that
way, however you can give initial values of class members in the last
parameter of the attachMovie() method, and the given values will be
initialized prior to the contructor's execution. E.g.:

class MyClass extends MovieClip {
  public var foo: Number;
  public var bar: String;

  public function MyClass() {
    trace("foo: " + foo);
    trace("bar: " + bar);
  }

}

myMC1 = mc.attachMovie("LinkageID", "myMC1", 1, {foo: 123, bar: "hello"}); myMC2 = mc.attachMovie("LinkageID", "myMC2", 2, {foo: 0, bar: "world"});

and the output is:

foo: 123
bar: hello
foo: 0
bar: world

If you wish to pass parameters to an instance placed on the stage
manually, then convert the movie clip symbol in the library to
component by using the Component Definition command in the right-click
menu of the library panel. There you can set the associated class and
the list of class' properties which can be set in the Parameters tab
of the Properties panel when you place an instance on the stage. The
given values of parameters will be initialized before the execution of
the constructor.

   Attila


_______________________________________________
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