View Full Version : duplicate an empty MC ?
milestrap
January 29th, 2003, 08:07 PM
Can this be done.. ?
when could you?
thanks for a solution.
M
lostinbeta
January 29th, 2003, 10:32 PM
Of course it can be done, it is just like duplicating any other movie clip ;)
But keep in mind your clip will be empty so it won't do you much good unless you plan on doing something with those clips.
Try this....
_root.createEmptyMovieClip("container", -1);
for (i=0; i<10; i++) {
_root.container.duplicateMovieClip("container"+i, i);
mc = _root["container"+i];
trace(mc);
}
senocular
January 29th, 2003, 11:00 PM
the problem comes into the drawing within an empty movieclip and copying that (in case thats what you meant). I did an example of a kind of workaround for that... but I think it was at were-here so its lost forever :(
the basic idea, though, was to save the drawing actions within a function and have that function run when you you duplicate a clip. Actually I think I overrided the duplicate prototype and just included in it a check for a 'creator' function which was what was associated with a drawn movieclip... if that function existed, it drew the object in the empty clip duplicate so you had a match.
milestrap
January 30th, 2003, 03:12 PM
Thanks for the help!!
Actually I would like to populate them with .swf files from an array..
how would I write that;
clipsArray = new Array ();
clipsArray[0] = ???
traced name = example.swf; ????
And then where would it go..
:)
lostinbeta
January 30th, 2003, 03:48 PM
Ermm, I am not sure but that might be CPU intensive.
Untested, but try this..
loadArray = ["clip1.swf", "clip2.swf", "clip3.swf", "clip4.swf"];
_root.createEmptyMovieClip("container", -1);
for (i=0; i<5; i++) {
_root.container.duplicateMovieClip("container"+i, i);
mc = _root["container"+i];
mc.loadMovie(_root.loadArray[i]);
mc._x = 25*i;
mc._y = 35*i;
trace(mc+": "+mc._x+", "+mc._y);
}
It duplicates the container, then uses loadMovie on the new clip and pulls which .swf file out of the array according to what "i" equals.
then it positions it on the x coordinates every 25 pixels for each clip and 35 pixels for each clip on the y coordinates.
The trace actions lets you see the x,y coordinates of each clip so you see what I mean by 25 pixels x and 35 pixels y
senocular
January 30th, 2003, 04:05 PM
I have a question... why duplicate empty movieclips when you can just create another one? This will keep the confusion down a little since you are using one method consistently (createEmpty) instead of two (createEmpty and duplicate)
lostinbeta
January 30th, 2003, 04:08 PM
Makes sense.
So you mean like this...?
loadArray = ["clip1.swf", "clip2.swf", "clip3.swf", "clip4.swf"];
for (i=0; i<5; i++) {
_root.createEmptyMovieClip("container"+i, i);
mc = _root["container"+i];
mc.loadMovie(_root.loadArray[i]);
mc._x = 25*i;
mc._y = 35*i;
trace(mc+": "+mc._x+", "+mc._y);
}
senocular
January 30th, 2003, 04:45 PM
yep, pretty much... but I dont know if there was a specific reason for wanting to duplicate or not? milestrap?
milestrap
January 30th, 2003, 05:29 PM
Well the reason for Duplicating.. is to keep byte size to a minimum.
and then of coarse loading seperate .swf later into those empty clips......
hhmm give me some time to put this to use...
thanks you kids rock...:)
lostinbeta
January 30th, 2003, 05:30 PM
Well its an empty movie clip, I am pretty sure it won't effect file size :-\
lostinbeta
January 30th, 2003, 05:35 PM
Keep in mind I am talking about if you are using Flash MX and create empty movie clips dynamically.
milestrap
January 30th, 2003, 05:35 PM
yup....
before I would load these .swf files into a holder_mc inside duplicated mc already on stage... but then you had no control over the .swf you just loaded. the _parent clip took presidence. ofcourse you couldn't remove it cause your .swf would dissapear as well. And I couldn't find work around. So this is why this question came up.
I'll need more help...don't go to far! :cowboy:
lostinbeta
January 30th, 2003, 05:37 PM
Refer to previous post ;) (we posted at the same time)
I have to go now, but I am always around. This is my favorite hangout.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.