Hi,
Whilst this suggestion is not good practice if you can get in at the start of a project - I would recommend doing things the way others have said, by using interfaces, I was given a very nice workaround for a situation I got stuck in recently.

I was given about 20 SWF & FLA files, where all the animation was done on the root timeline - not in a movieclip. These were to be loaded into a shell application and I needed to have some control over the playback of the animations, know when they finished or hit certain frames etc. It would have been perfect if the animations were each contained within a MovieClip that was linked to a class of my choosing, but I did not get to speak to the animators as I was lower down in the food chain for this job. As I did not wish to copy and paste thousands of frames of animation into child clips with the correct class linkage, I asked for some help and was told, I could "recast" the loaded SWF movieclips into a class of my choosing. This worked beautifully and saved me hours of extra work,

   Credit to [EMAIL PROTECTED] for his solution below -thanks a million!

"Hi,

I think adding to the prototype would be the easiest way of recasting an
external swf into a class.  It's like setting up a class linkage in the
library except you can't do that with external swfs (as you already
know).

Once you got the swf loaded into external_mc you can:

// recast it as NewClass
external_mc.__proto__ = NewClass.prototype;
external_mc.__constructor__ = NewClass;
external_mc.__constructor__.apply(external_mc);

If you wanted to pass arguments into the constructor you can change last
line to:
external_mc.__constructor__.apply(external_mc, arg1, arg2, ..., argN);

It might not look nice, but it works nice.  The external swf functions
and behaves just like a symbol would be if you loaded it from your
library and the class linkage was setup.

Hope this helps.

Matthew Jacobi
"
Adobe Consulting - EMEA - MAD

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