Multidimensional array not working right

Hi there. I hope someone here can help me, because I’m pretty stuck…

I’m creating a flash movie which reads an XML file and puts the content in an array.

The xml file defines categories, each of which has a title and some chapters, which in turn have their own page number, title and filename for content (just a string defining the filename).

What I’m trying to do is create an array called categories, which contains the title and chapters for each category. Considering the fact that each category has multiple chapters, I put these chapters in a different array, which I then put in the categories array.
The code that makes all this happen is as follows:

//fill chapter array
chapters.push({page: chpage, title: chtitle, file: chcontent});

//fill categories array
categories.push({title: catitle, content: chapters});

The chapters.push bit happens in a loop for each category, after that finishes, chapters is emptied and the next category is looped and filled.

It all works like a charm, except for one problem that screws it all up: when I use categories.push, the new information is not only added at a new index number in the categories array, it also overwrites the previous index numbers with the same content!

I have no idea how in the world this could happen, I’ve tried all possible locations in the code to put the categories.push command, I’ve tried using a hardcoded number to define the index number to put the content… nothing works!

I’ve attached the output flash gives, showing exactly what happens, as well as the xml file and the flash sourcefile.
If anyone has any suggestions whatsoever, I’d be extremely grateful, because this frustrates me as you wouldn’t believe! So thanks in advance for any and all ideas.