Okay, here's the drill.

I have a MovieClip — call it FooA — that's been linked to an AS2 class — call it FooA_Class — (that extends MovieClip and does lots of other useful things.)

In that MovieClip, I have another MovieClip — SubFooA — that's been exported and given a proper instance name. In FooA_Class there's an instance variable that has the same name as the instance name for SubFooA (that idiom is weird, but okay..)

I would like to, in ActionScript, dynamically instantiate and render onto the stage several instances of FooA — it's a MovieClip, after all — it has some visual things in itself, like colored blocks and stuff.

Now, I want to also, in ActionScript, call a bunch of the useful methods that FooA_Class has.

What's the idiom for doing such a thing??

I've tried what the Java guy in me says to, like instantiate FooA and do things with it:

var mFooA:FooA = new FooA();
mFooA.doSomeMethod();

But, now I can't get it on the stage properly, even with various incarnations of attachMovie in either the constructor of FooA, or right there after the constructor (registerClass/attachMovie)

Then I try this confusing idiom:

Object.registerClass("mFooA", FooA);
_root.attachMovie("FooA", "FooA", 1);

The MovieClip FooA appears on the stage, but that's it — I can't call useful methods on it as I have no proper handle to the instance.

If I do this:

Object.registerClass("mFooA", FooA);
var aObject:Object = _root.attachMovie("FooA", "FooA", 1);

what is returned from attachMovie isn't properly cast to my class type — which is a bit odd. I mean, if I do this:

Object.registerClass("mFooA", FooA);
var aObject:FooA_Class = _root.attachMovie("FooA", "FooA", 1);

Flash complains — whatever the equivalent of a class cast error it spouts..type mismatch or something?

So, the basic question is this: how can I programmatically instantiate and deliver to the stage a movie clip linked to my own custom class (which extends MovieClip) and then actually call the useful methods contained within that linked custom class?

This _has_ to be easy, no?

Julian


Julian Bleecker, Ph.D.
http://research.techkwondo.com
[EMAIL PROTECTED]



_______________________________________________
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