I'm creating a tool that dynamically loads in content (images/text) into a swf at runtime (we are optimising banner ads). We are donig this by replacing the MovieClips in a swf with new MovieClips with the loaded content. One requirement we have now is to load in the dynamic content into MovieClips that have Tweening applied to the.
What I've found in the current method we use, where we replace a MovieClip with a new one with content loaded, is that any Tweening on the original MovieClip is not applied to the new one. I was thinking of instead of creating a new MovieClip, duplicating the exisiting MC (that has all the Tweening) and in the new copy load in my optimised content.
Is there a way, using ActionScript to programatically duplicate a MC, and keep any Tweening that has been applied to the original MC?
Tweens tend to be short, like a fade in, slide in, or affect some property. Are you apply a constant tween or a yoyo type of effect of some sort?
There's a million ways to do this, we just need to know what you want it to do. Code examples preferred.
A couple things. I'll stick on topic to be easy at first and then make a recommendation.
First, Tweens are applied by you, when you want them to happen. Once you apply a tween and fire it off, at the end of that tween it will never happen again. Not until you tell it that it should and even then you will need to rebuild your tween. From what you say you suggest to me (and I can be wrong) that you think a tween is an event based class where when a movieclip has a tween applied it will be fired off every time that movieclip changes, or loads, etc. That's not true if that's the case. You must explicitly set up the environment for that to happen.
In the code you use to load the next SWF it is your responsibility to first manually tell the current SWF to tween out. Once that's done it's your responsibility to load in the new SWF. Once you detect it's loaded, it's your responsibility to re-apply the tween to fade it in. There is no automatic nature here. You tell it to tween, every time you want it to.
Second, consider using a light-weight Tween class such as http://www.greensock.com/tweenlite/ TweenLite. The are smaller in file size, much faster and very easy to use. They support extended features and are optimized well beyond the built-in tween class. Examples and demonstrations are provided on that site for the class. It's extremely easy to use and if you do feel free to post code or ask for help if you need it.