Ben you're doing the right thing by having MyClass contain the clip you load
rather than extend it.  You can't cast a MovieClip (or any object) to a new
type that's lower in the class hierarchy than the original object.

Doug

-----Original Message-----
From: ben gomez farrell [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 02, 2007 9:11 AM
To: Flashcoders mailing list
Subject: [Flashcoders] One more AS3 question!

So, I was wondering if there's anyway to do this....

I have some graphics in my SWF.  I'm embedding them and compiling with the
Flex SDK.  The graphics are coming in as MovieClips, but I want a little
more functionality, so I'd like to extend the clip and encapsulate that
additional functionality in a class.

I've discovered the magic of typing something as.... I can bring in a
movieclip and do a var mynewsprite:Sprite = mymovieclip as Sprite.

But I actually want to type something "up".  With type "as" I can only type
something as something the object extends from.  I can type a movieclip as a
sprite or a display object.

I want to take my movieclip instance from the library (I don't want to
specify a class name, because I'd prefer to avoid the Flash alpha compiler
and just do everything in the Flex SDK).  I want to bring that movieclip
onto the stage and magically make it a MyClass movieclip (where MyClass
extends movieclip).

For now I'm just working around it by passing it into MyClass, and not
making MyClass extend anything, just keeping the movieclip as a variable to
use in the class.

Anyway, I know I'm being really picky (don't want to specify a class, don't
want workarounds), it's really for learning purposes rather than .... "I
need this done right now!!!"

So anybody know how to turn a movieclip into an extended movieclip through
code?


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