I really need HELP with duplicating movies

I tried to duplicate a movie in runtime (used the mc.duplicateMovieClip function). It duplicates just fine… but the function it had in its first frame doesn’t work for the duplication…
To say it in another way…
Example: I created mc and in its first frame i wrote the function


function write_some(s) {
trace(s);
}

And I wrote this for a button in the _root on the on release part


mc.duplicateMovieClip("mc1",_root.getNextHighestDepth());
_root["mc1"].write_some("test");

.
The movieclip duplicates just fine but no output!! How to make it work??

I have to say, this has me scratching my head - not sure why it doesn’t work.

but, you can get the same results by doing this way, if you can do it this way:


// duplicate your movie - but store it in a variable

var dup = mc.duplicateMovieClip("mc1", _root.getNextHighestDepth());

// you can dynamically set this function on the fly - even though it exists within the clip already - this probably overwrites that one

dup.write_some = function(s) {
	trace("this is dup: "+s)
}

// then you can call the code on your duplicate clip
dup.write_some("this works");

Never mind… i figured it out…:smiley: thnks anyway… your method was ok but think that i have a function that has 65 lines of code… to adapt it to the dup.wr… it’s not worth it… but i have realized that flash cannot run functions of a duplicated movie in the same on(release) block…:smiley: Weird… right??

interesting - thanks for that info!