# I need help with loading xml, CreateEmptyMC and calling function

**URL:** https://forum.kirupa.com/t/i-need-help-with-loading-xml-createemptymc-and-calling-function/210015
**Category:** flash
**Created:** [December 14, 2006, 3:30am UTC](https://forum.kirupa.com/t/i-need-help-with-loading-xml-createemptymc-and-calling-function/210015 "2006-12-14T03:30:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![samroni](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@samroni](https://forum.kirupa.com/u/samroni)
#### Post date: [December 14, 2006, 3:30am UTC](https://forum.kirupa.com/t/i-need-help-with-loading-xml-createemptymc-and-calling-function/210015/1 "2006-12-14T03:30:11Z")

</div>

Hi guys, i’ve got a question which i don’t know exactly what my problem is. So i don’t know what to search in threads search.

i downloaded bookflip from iparigrafika.hu, some of you might know. and the book requires you to fill “page” symbol in library with pictures.

now, i want the page to be created using xml.

- i got thumbnails of pictures, when you click the thumb, you open the thumbnail xml you click (e.g. thumb 1, clicked, then you get 1.xml)

- the xml is successfully called.

- book pages have to be called from library, so they have identifier each of them (e.g. page1 have name page1)

\*\*the question now is: how to write the script, since i can’t put the symbol (page) on stage and must call the function in a row?

what i want: to make empty MC then load pictures from xml then call the function\*\*

```auto

addpage(page1);
addpage(page2);
addpage(page3);
//etc

```

the following is the code i use:

```auto

xmlPersonalData = new XML();
xmlPersonalData.ignoreWhite = true;
xmlPersonalData.onLoad = PersonalXML;
xmlPersonalData.load("xml/"+_root.number+"/"+_root.number+".xml");
function PersonalXML(loaded) {
    if (loaded) {
        xmlPersonalNode = this.firstChild;
        _root.loadPortfolio = [];
        _root.portfolio_img = [];
        
        _root.totalPortfolioPic = xmlPersonalNode.childNodes[2].childNodes.length;
        //trace(_root.totalPortfolioPic); //returns 6
        
        _root.portfolio_img = createEmptyMovieClip("portfolio_img", this.getNextHighestDepth());
        //trace(portfolio_img); //MC exists
        
        for (pic=0; pic<_root.totalPortfolioPic; pic++) {
            _root.loadPortfolio[pic] = xmlPersonalNode.childNodes[2].childNodes[pic].firstChild.nodeValue;
            //trace(_root.loadPortfolio); //returns all JPGs are called correctly
            
            //this is where i get confused
            _root.portfolio_img.duplicateMovieClip("portfolio_img"+pic, pic);
            
            _root.portfolio_img[pic].loadMovie(_root.loadPortfolio[pic], 1);

        }
        
        portfolio_mc.gotoAndPlay("initialize");

} else {
        trace ("file not loaded!");
    }
}

```

few explanation:

- the preceding code is the parent. the book is the child and has its own code
- the book is called portfolio\_mc in stage

following code is the line from book to call pages from library:

```auto

//trace(_root.totalPortfolioPic); //Returns 6
for (z=1; z<=_root.totalPortfolioPic; z++) {
    addPage("_root.portfolio_img"+z);
    //i'm not sure what im writing here, but it supposed to call the emptyMC filled with pictures from xml

    //addPage("page"+z); // returns working like when you do it manually
}
/*
addPage("page1");
addPage("page2");
addPage("page3");
addPage("page4");
addPage("page5");
addPage("page6");
addPage("page7");
addPage("page8");
addPage("page9");
addPage("page10");
addPage("page11");
addPage("page12");
addPage("page13");
addPage("page14");
addPage("page15");
addPage("page16");
*/

```

i really appreciate it anyone who help me. i really need any help i can get. if you need the master file. let me know.

Thanks a lot…
