# Joey Lott's AS 2.0 vids - a question

**URL:** <https://forum.kirupa.com/t/joey-lotts-as-2-0-vids-a-question/206201>\
**Category:** Uncategorized\
**Created:** [November 6, 2006, 4:19am UTC](https://forum.kirupa.com/t/joey-lotts-as-2-0-vids-a-question/206201 "2006-11-06T04:19:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fingers](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@Fingers](https://forum.kirupa.com/u/Fingers)\
**Post date:** [November 6, 2006, 4:19am UTC](https://forum.kirupa.com/t/joey-lotts-as-2-0-vids-a-question/206201/1 "2006-11-06T04:19:53Z")

</div>

I’ve been following Joey Lott’s Advanced AS 2.0 video tutorials from [Lynda.com](http://Lynda.com), and am just getting into the part where he starts creating custom classes. While I understand the following code, more or less, I am curious to know how I would go about making a slight modification, and have it so that each Book instance is preserved rather than overwritten whenever the for loop increments. I suppose the way to do this would involve naming the variable dynamically… something like var bkItem\*:Book. But how is that done?

```auto

var myXML:XML = new XML();
initializeXML();
function initializeXML():Void {
    myXML.ignoreWhite = true;
    myXML.onLoad = function(bSuccess:Boolean):Void {
        var bkItem:Book;
        var xnBook:XMLNode;
        for (i=0; i<this.firstChild.childNodes.length; i++) {
            xnBook = this.firstChild.childNodes*;
            bkItem = new Book(xnBook.attributes.title, xnBook.attributes.author, xnBook.firstChild.nodeValue);
            trace(bkItem.toString());
        }
    };
    myXML.load("library.xml");
}

```

```auto

class Book {
    private var _sTitle:String;
    private var _sAuthor:String;
    private var _sDescription:String;
    function Book(sTitle:String, sAuthor:String, sDescription:String) {
        _sTitle = sTitle;
        _sAuthor = sAuthor;
        _sDescription = sDescription;
    }
    public function toString():String {
        var sOutput:String = _sTitle+newline+_sAuthor+newline+_sDescription;
        //trace(sOutput);
        return sOutput;
    }
}

```

Fingers
