On 10/11/06, Muzak <[EMAIL PROTECTED]> wrote:

> When using the attachMovie method, it is possible to set values of
> member variables. These values are set before the constructor is
> executed.
> Why that?

The set variable value can be used immeditaly in the initializing process, so 
will be drawn faster.
So the component will be drawn with the 'new value', rather than with a 
'default value' and then redrawn with the 'new value'.
Might not be a biggy if the variable doesn't have a huge inpact on the 
component, but if that particular variable value affects the
layout (so the whole component needs to be redrawn) it does.

What's more - if you were using a straight OOP class for your
MovieClips (like AS3 does), you could have a constructor that took
parameters e.g.
var button:Button=new Button('label');

But you can't do that in AS2 because of the way MovieClips/Components
are created (attachMovie instead of new()) so you need some way of
passing initialisation variables. The method Macrodobe came up with is
to pass the initialisation variables as an object argument to
attachMovie(). It's a workaround because of the need to rely on
attachMovie(). And happily, it's gone in AS3.

> And furthermore:
> Even private member variables can set this way and even the
> constructor can be private. And why that?
>
> Is there a special explanation or something obvious I missed?
>
I have to guess here really.. attachMovie is a MovieClip method, which is a 
dynamic class.

I'd imagine it's because the assignment of the variables actually
happens at runtime, and because AS2 compiles down to the same bytecode
as AS1, the runtime engine doesn't actually _know_ whether properties
are public or private (in AS2 as opposed to AS3, public and private
are only meaningful at _compile_ time).

So it just looks through the initialisation object (as if you were
doing a for... in... ), and sets variables on the new clip - it
doesn't know anything about access permissions.

Ian
_______________________________________________
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