# XML nausing me up

**URL:** <https://forum.kirupa.com/t/xml-nausing-me-up/260457>\
**Category:** flash\
**Created:** [May 15, 2008, 7:54pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457 "2008-05-15T19:54:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rumblesushi](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rumblesushi](https://forum.kirupa.com/u/rumblesushi)\
**Post date:** [May 15, 2008, 7:54pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/1 "2008-05-15T19:54:37Z")

</div>

Hi,

As stated the other day, XML is something I ignored until recently, now that I see how useful it is I shall be using it all the time.

I made my first XML gallery yesterday, and now I’m just polishing it up.

I have a problem though. I’m loading thumbnails into holders in the XML onLoad loop, and I am also assigning the holder a preloader.

Now this worked perfectly in another non XML loop, with the exact same preloader function etc.

In the XML loop it doesn’t. When the preloader is assigned to the holder, it hasn’t yet registered that a JPG is being loaded into it, it is preloading what it thinks is just an empty MC, and thus sets percentloaded to 100, and the preloader is void.

Now this can be fixed fairly easily by making another loop a few frames down the timeline, to give it time to register that something is being loaded into the holder.

However, I don’t want to do this, it’s stupid, I want to keep things nice and neat all in 1 loop.

For you XML savvy kirupians, what else can I do? I’m a bit confused because I thought the XML onLoad function was to prevent hiccups like this.

Any idea of what I can do other than having to create another loop to load the thumbs a few frames down?

Here is the XML loop…

```auto
xml.onLoad = function(loaded) {
 if (loaded) {
  total = this.firstChild.childNodes;
  for (var i = 0; i<total.length; i++) {
   description.push(total*.firstChild.firstChild);
   thumbs.push(total*.firstChild.nextSibling.firstChild);
   bigpics.push(total*.firstChild.nextSibling.nextSibling.firstChild);
   if (i%4 == 0) {
    b = 0;
    c++;
   }
   initObj = {_x:h_pos+b*h_spacing, _y:v_pos+c*v_spacing};
   bob = attachMovie("thumb", "thumb"+i, i, initObj);
   thumbholders.push(bob);
   bob.holder.loadMovie("thumbs/"+thumbs*);
   bob.id = i;
   thumbloader(bob);
   bob.onRollOver = function() {
    testbox.text = this.id;
    this.gotoAndStop(2);
   };
   bob.onRollOut = function() {
    this.gotoAndStop(1);
   };
   bob.onRelease = function() {
    hidethumbs();
    bigholder.holder.loadMovie("thumbs/"+bigpics[this.id]);
    bigloader(bigholder);
   };
   b++;
  }
 }
};
xml.load("illustration.xml");

```

By the way, how do some of you paste the code with the AS colourcoding in tact? Surely you don’t do this manually? 🙂

Cheers,  
Joe

---

<div class="post-metadata">

**Author:** ![creatify](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@creatify](https://forum.kirupa.com/u/creatify)\
**Post date:** [May 16, 2008, 12:57am UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/2 "2008-05-16T00:57:59Z")

</div>

AS FORMATTING:  
when posting - just wrap any items you want to appear formatted as action script with:

open bracket+“as”+close bracket  
then your code goes here:  
open bracket+slash+“as”+close bracket

LOADMOVIE:  
Look into using the MovieClipLoader class versus loadMovie… I may get some fire from saying this, but loadMovie is horrible… the moviecliploader class contains methods for checking progress.

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [May 16, 2008, 1:12am UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/3 "2008-05-16T01:12:10Z")

</div>

[ot][noparse][noparse][/noparse][/noparse] allows you to post tags like [noparse]

```auto

```

[/noparse] by the way.[/ot]

---

<div class="post-metadata">

**Author:** ![rumblesushi](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rumblesushi](https://forum.kirupa.com/u/rumblesushi)\
**Post date:** [May 16, 2008, 10:18am UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/4 "2008-05-16T10:18:32Z")

</div>

Thanks creatify, unfortunately it didn’t work, the same thing happened, it didn’t recognise that a JPG was being loaded into the target MC by the time the preloader was called. I can’t see any way round it but delaying loading the images in from XML.

At what point do you call your preloader once an image from XML is loaded in?

---

<div class="post-metadata">

**Author:** ![rumblesushi](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rumblesushi](https://forum.kirupa.com/u/rumblesushi)\
**Post date:** [May 16, 2008, 12:34pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/5 "2008-05-16T12:34:04Z")

</div>

Incidentally, these 2 bits of code do the same thing - which is preferable?

```auto

total = this.firstChild.childNodes;
		for (var i = 0; i<total.length; i++) {
			description.push(total*.childNodes[0].firstChild.nodeValue);
			thumbs.push(total*.childNodes[1].firstChild.nodeValue);
			bigpics.push(total*.childNodes[2].firstChild.nodeValue);
}

```

```auto

total = this.firstChild.childNodes;
		for (var i = 0; i<total.length; i++) {
			description.push(total*.firstChild.firstChild);
			thumbs.push(total*.firstChild.nextSibling.firstChild);
			bigpics.push(total*.firstChild.nextSibling.nextSibling.firstChild);
}

```

I was thinking the first one, logically, as if each element had many childNodes, you’d end up writing nextSibling 10 times.

---

<div class="post-metadata">

**Author:** ![rumblesushi](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rumblesushi](https://forum.kirupa.com/u/rumblesushi)\
**Post date:** [May 16, 2008, 3:05pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/6 "2008-05-16T15:05:07Z")

</div>

How odd. The above code works perfectly, preloader n’ all, with just one amendment.

bob.createEmptyMovieClip(“holder”, 1);

Before bob.holder.loadMovie

Instead of having the holder MC already there, I generate it in the XML loop and it works. I don’t understand why though, why would an XML loop take longer to target an existing MC, and a normal, non XML loop doesn’t.

---

<div class="post-metadata">

**Author:** ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)\
**Post date:** [May 16, 2008, 3:05pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/7 "2008-05-16T15:05:48Z")

</div>

why don’t you simply use a class to parse automatically the xml?

[http://www.sephiroth.it/file\_detail.php?id=134](http://www.sephiroth.it/file_detail.php?id=134)

---

<div class="post-metadata">

**Author:** ![rumblesushi](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rumblesushi](https://forum.kirupa.com/u/rumblesushi)\
**Post date:** [May 16, 2008, 5:23pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/8 "2008-05-16T17:23:42Z")

</div>

Pier, how would it help me in this instance?

---

<div class="post-metadata">

**Author:** ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)\
**Post date:** [May 16, 2008, 6:52pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/9 "2008-05-16T18:52:57Z")

</div>

You would not have to parse your xml by hand… don’t you think that’s helpful?

---

<div class="post-metadata">

**Author:** ![rumblesushi](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rumblesushi](https://forum.kirupa.com/u/rumblesushi)\
**Post date:** [May 17, 2008, 2:01pm UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/10 "2008-05-17T14:01:54Z")

</div>

Oh I see I see, so you’re referencing my question about which parsing method is preferable, rather than my original issue?

OK sure, I’ll try it out.

Im not used to using classes like this, I’m a Flash MX boy, I’m used to having to code my own tweens etc, only recently have I even started to use tween engines 😃

I’m still settling in to this new Flash era.

Thanks for the info.

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [May 19, 2008, 2:11am UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/11 "2008-05-19T02:11:22Z")

</div>

Don’t know if I mised anything but what does thumbs\*return when traced?

---

<div class="post-metadata">

**Author:** ![rumblesushi](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rumblesushi](https://forum.kirupa.com/u/rumblesushi)\
**Post date:** [May 19, 2008, 9:01am UTC](https://forum.kirupa.com/t/xml-nausing-me-up/260457/12 "2008-05-19T09:01:01Z")

</div>

Nathan - it returns the list of JPG names 🙂
