all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

duplicateMovieClip and createEmptyMovieClip



duplicateMovieClip and createEmptyMovieClip kgui
1/22/2005 8:38:29 PM
flash actionscript: Hi, I have two questions about the usage of duplicateMovieClip() A) I have
created EmptyMovieClips with the createEmptyMovieClip() function. such as;
_root.MainClip.severalCreatedEmptyMC When I perform a duplicateMovieClip() on
MainClip, will also the severalCreatedEmptyMC, inside MainClip be Copied ? B)
Is it possible to duplicateMovieClips to other Targets than the current one.
Like; _root.clipA.ChildA to _root.anotherClip,clipAcopy.ChildAcopy Thanks,
Pieter
Re: duplicateMovieClip and createEmptyMovieClip kglad
1/22/2005 9:27:40 PM
A) no, movieclips created via actionscript (using duplicateMovieClip() and
createEmptyMovieClip() ) are not duplicated when you execute a
duplicateMovieClip() on the parent. movieclips created in the authoring
environment are duplicated when duplicateMovieClip() is applied to the parent.

B) no, you cannot control the inheritance or lineage of movieclips after
they've been created.
Re: duplicateMovieClip and createEmptyMovieClip kglad
1/22/2005 9:30:25 PM
Re: duplicateMovieClip and createEmptyMovieClip kgui
1/23/2005 10:27:13 AM
That's a bummer!
I have to rethink my project concept, downloading a external movieclip and using it as copies on several levels on my main movieclip.
Re: duplicateMovieClip and createEmptyMovieClip rlc5611
1/23/2005 10:41:15 AM
Re: duplicateMovieClip and createEmptyMovieClip bgoulette612
1/22/2006 7:36:23 PM
I'm having a similar issue: I have an externally loaded image (using
MovieClipLoader) that I want to place within different movieclips. From what I
understand, MovieClip.duplicateMovieClip(newName, depth) just creates a
duplicate on MovieClip's parent. Great -- even though that appears to be
broken, too. Once I've duplicated a movieclip, is there anyway to create a copy
of it -- not a reference -- and then put that copy where I want to?

Or is there anyway to somehow cram an externally loaded image into the library
-- at least some way to make Flash think the image is in the library, so I can
use attachMovie? Please help! Thanks!
Re: duplicateMovieClip and createEmptyMovieClip NSurveyor
1/22/2006 9:03:56 PM
You can use the new BitmapClass to create a copy of a movieclip and place it
anywhere (but note, it will be like a snap shot)

Put this on frame 1:

import flash.display.BitmapData;
import flash.geom.Matrix;
MovieClip.prototype.createCopyOf = function(target, newName, depth,
initObject) {
var bmp = new BitmapData(target._width, target._height, true, 0);
var smc = this.createEmptyMovieClip(newName, depth);
smc.createEmptyMovieClip('bitmap_mc',0);
var x = target.getBounds(target).xMin;
var y = target.getBounds(target).yMin;
smc.bitmap_mc._x = x;
smc.bitmap_mc._y = y;
smc.bitmap_mc.attachBitmap(bmp, 0);
bmp.draw(target, new Matrix(1, 0, 0, 1, -x, -y));
return smc;
};

Then, say you have a clip: this.x.abc and you want to create a new clip,
this.y that will be a copy. You can use:

var copyClip = this.createCopyOf(this.x.abc,'y',1);
//creates and returns a clip
trace(this.y);
trace(copyClip);
//do something, e.g.
this.y.startDrag(true);
Re: duplicateMovieClip and createEmptyMovieClip NSurveyor
1/22/2006 9:34:18 PM
I had an initObject in there, yet I never used it.. Well, you can either just
get rid of that part, or if you want, you can add the functionality:

import flash.display.BitmapData;
import flash.geom.Matrix;
MovieClip.prototype.createCopyOf = function(target, newName, depth,
initObject) {
var bmp = new BitmapData(target._width, target._height, true, 0);
var smc = this.createEmptyMovieClip(newName, depth);
smc.createEmptyMovieClip('bitmap_mc',0);
var x = target.getBounds(target).xMin;
var y = target.getBounds(target).yMin;
smc.bitmap_mc._x = x;
smc.bitmap_mc._y = y;
smc.bitmap_mc.attachBitmap(bmp, 0);
bmp.draw(target, new Matrix(1, 0, 0, 1, -x, -y));
for(var prop in initObject){
smc[prop] = initObject[prop];
}
return smc;
};

and then for example

var copyClip = this.createCopyOf(this.x.abc,'y',1,{_x:100,_y:50,_alpha:50});
AddThis Social Bookmark Button