# duplicateMovieClip on mc with dynamic content

**URL:** <https://forum.kirupa.com/t/duplicatemovieclip-on-mc-with-dynamic-content/62387>\
**Category:** flash\
**Created:** [August 27, 2004, 11:11am UTC](https://forum.kirupa.com/t/duplicatemovieclip-on-mc-with-dynamic-content/62387 "2004-08-27T11:11:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![warne](https://avatars.discourse-cdn.com/v4/letter/w/e99b99/32.png) [@warne](https://forum.kirupa.com/u/warne)\
**Post date:** [August 27, 2004, 11:11am UTC](https://forum.kirupa.com/t/duplicatemovieclip-on-mc-with-dynamic-content/62387/1 "2004-08-27T11:11:11Z")

</div>

I try to duplicate a mc wich has dynamic loaded content. The mc is loaded but not the content. Why?

All these actions are done in a control mc in the beginning of the flash movie, that also loads XML content - which pictures to load is determined in the XML file.

The code:

(sorry for the danish comments in the code…)

* * *

onClipEvent(load) {  
//opret globale variable  
\_global.startPicMove = “”;  
\_global.mouseIsOver = “false”;  
\_global.moviewidth = 738;//filmens længde  
\_global.centerpos = \_global.moviewidth/2;//midten af maincontainer  
\_global.pics\_space = 5;//mellemrum ml. billederne  
\_global.speed = 20;//hastighed af træk i billedet  
\_global.turn = “left”;//hvilken vej drejer billederne

// — LOAD XML - og generer billeder —

//funktionen generatePics som parser XML indhold, skaber og attacher indhold/movieclips med funktioner  
function generatePics(pics\_xml) {  
//trace (pics\_xml);

//opret movieclips som skal holde billederne og flyttes horisontalt  
//\_root.createEmptyMovieClip(“maincontainer”,1);  
var pic\_maincontainer = \_root.maincontainer;  
//pic\_maincontainer.createEmptyMovieClip(“container”,1);  
var pic\_container = \_root.maincontainer.container;

//set start indikator  
\_global.startPicMove = “start”;  
trace (“startindikator”);

//flyt maincontainer  
pic\_maincontainer.onEnterFrame = function (){  
//trace (“enter frame maincontainer”);

//scroll billederne fra start  
if ((\_global.startPicMove == “start”) && (\_global.mouseIsOver == “false”)) {  
pic\_maincontainer.\_x -= 1;  
}  
//gør billederne scrollbare hvis musen er over filmen  
if (this.hitTest(\_root.\_xmouse, \_root.\_ymouse, true)) {  
\_global.mouseIsOver = “true”;  
//\_global.startPicMove = “”;//stop automatisk move  
//trace (“maincontainer mouseover”);  
}  
else {  
\_global.mouseIsOver = “false”;  
//trace (“maincontainer mouseout”);  
}

//scroll billederne udfra mouseposition  
if (\_global.mouseIsOver == “true”) {  
if (\_xmouse \> \_global.centerpos) {  
//trace ("x mouse pos: " + \_xmouse);  
\_global.turn = “right”;  
xpos\_factor = ((\_xmouse - \_global.centerpos)/\_global.centerpos)_\_global.speed;  
//trace ("xpos\_factor: " + xpos\_factor);  
this.\_x += xpos\_factor;  
}  
if (\_xmouse \< \_global.centerpos) {  
//trace ("x mouse pos: " + \_xmouse);  
\_global.turn = “left”;  
xpos\_factor = ((\_global.centerpos - \_xmouse)/\_global.centerpos)_\_global.speed;  
//trace ("xpos\_factor: " + xpos\_factor);  
this.\_x -= xpos\_factor;  
}  
}

}//end maincontainer onEnterFrame

//opret lokale variable  
var curr\_node;  
var curr\_pic\_name;  
var curr\_pic\_holder;  
var curr\_pic\_x;  
var curr\_pic\_y;  
var curr\_pic\_link;  
var curr\_pic\_info;  
var nodes\_xml = pics\_xml.firstChild;//første node i hierarkiet - topcontainer node  
//trace ("first child = " + pics\_xml.firstChild);  
//var curr\_by = container.createEmptyMovieClip(name, depth);

//opret globale variable  
\_global.numPics = nodes\_xml.childNodes.length;//antal billeder  
trace ("antal billeder: " + \_global.numPics);

//loop gennem alle XML noder, hiv text mm ud og skab movieclip med funktioner  
for (var i=0; i\<nodes\_xml.childNodes.length; i++) {  
//trace ("antal noder i alt = " + nodes\_xml.childNodes.length);  
curr\_node = nodes\_xml.childNodes\*;  
//trace ("current node = " + nodes\_xml.childNodes\*);

//opret/dupliker nye movieclip i et container movieclip og load billeder ind i disse  
//curr\_pic\_holder = pic\_container.createEmptyMovieClip(“pic\_holder”+i,1+i);  
curr\_pic\_holder = \_root.maincontainer.container.pic\_holder\_clp.duplicateMovieClip(“pic\_holder”+i, 1+i);  
//opret endnu en container til at holde billedet - ellers virker efterfølgende actions ikke  
curr\_pic\_mc = curr\_pic\_holder.createEmptyMovieClip(“pic\_mc”+i,1+i);  
curr\_pic\_name = curr\_node.attributes.pic\_name;  
//trace ("picname: " + curr\_pic\_name);  
curr\_pic\_mc.loadMovie(curr\_pic\_name);//henter billede  
curr\_pic\_x = (curr\_node.attributes.x \* i) + (\_global.pics\_space\*i);  
//trace ("x pos: " + curr\_pic\_x);  
curr\_pic\_holder.\_x = curr\_pic\_x;  
curr\_pic\_holder.\_y = 0;

//definer properties/variable som knyttes til holder movieclip  
curr\_pic\_holder.navn = curr\_pic\_holder.\_name;  
//trace("pic holder navn: " + curr\_pic\_holder.navn);  
curr\_pic\_holder.sti = curr\_pic\_holder;  
//trace("pic holder sti: " + curr\_pic\_holder.sti);  
curr\_pic\_holder.container = curr\_pic\_holder.\_parent;  
//trace("pic holder container: " + curr\_pic\_holder.container);  
curr\_pic\_holder.link = curr\_node.attributes.linkurl  
//trace("pic holder url: " + curr\_pic\_holder.link);  
curr\_pic\_holder.info = curr\_node.attributes.info;  
//trace("pic holder info: " + curr\_pic\_holder.info);

//opret funktioner på det movieclip som indeholder movieclips med billederne  
curr\_pic\_holder.onLoad = function() {  
//trace("Load: " + this.\_name);  
}  
curr\_pic\_holder.onRollOver = function() {  
//trace ("pic rollover: " + this.\_name);  
\_root.infotext\_txt.html = true;  
\_root.infotext\_txt.htmlText = this.info;  
//\_root.infotext\_txt = this.info;  
//opret og anvend textFormatObjekt til formattering af text  
infotext\_txt\_format = new TextFormat();  
infotext\_txt\_format.bold = true;  
infotext\_txt\_format.align = center;  
\_root.infotext\_txt.setTextFormat(infotext\_txt\_format);  
}  
curr\_pic\_holder.onRollOut = function() {  
//trace ("pic rollout: " + this.\_name);  
\_root.infotext\_txt.htmlText = “”;  
}  
curr\_pic\_holder.onRelease = function() {  
getURL(this.link, “\_blank”);  
}

}//end for loop

//dupliker container ift. hvilken vej der scrolles (billeder går i ring)

pic\_container.onEnterFrame = function (){  
//trace (“enter frame container”);

if (\_global.turn == “left”) {

```
trace ("turn: " + _global.turn);
_root.maincontainer.container.duplicateMovieClip("container_right", 2);
trace ("container x: " + _root.maincontainer.container._x);
trace ("maincontainer x: " + _root.maincontainer._x);
trace ("container width: " + _root.maincontainer.container._width);
_root.maincontainer.container_right._x = _root.maincontainer.container._x + _root.maincontainer.container._width;
trace ("container right x: " + _root.maincontainer.container_right._x);
trace ("container right name: " + _root.maincontainer.container_right._name);
trace ("container right width: " + _root.maincontainer.container_right._width);    

```

}  
}

}//end function generatePics

//definer et nyt XML objekt  
pics\_xml = new XML();  
pics\_xml.ignoreWhite = true;  
//funktion når XML er loaded færdig  
pics\_xml.onLoad = function(ok){  
if (ok){  
generatePics(this);  
}  
};  
// load XML  
pics\_xml.load(“pics.xml”);  
trace (“XML loaded”);  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2004, 3:18am UTC](https://forum.kirupa.com/t/duplicatemovieclip-on-mc-with-dynamic-content/62387/2 "2004-08-28T03:18:34Z")

</div>

This is known limitation in the flash player. You have to reload it again, However since the image will be cached after its loaded the first time, it would load almost instantly the next time.

You can read bit more about it here.

[http://www.macromedia.com/support/flash/ts/documents/dupswf.htm](http://www.macromedia.com/support/flash/ts/documents/dupswf.htm)
