Important note on AS2 properties

I neglected to mention this important point in OOP4AS2#2 – when creating array or object properties for classes, you must initialize them in your constructor as with “goodList” below. The “badList” array property below will share the same data amongst all instances of the class:

class MyList {
var goodList:Array;
var badList:Array = new Array();
MyList = function() {
goodLlist = new Array();

Bokel has a good description of the issue, with some sample code here.

Grant Skinner

The "g" in gskinner. Also the "skinner".



  1. What is this Viagra guy doing here. Anyway, thanks for the lead to Bokel’s blog.

  2. I have a serious problem with Classes using other classes.

    I try to use the XML-class inside my own class, the XML class has an event onLoad, I have no problems if I define the xml-class as static outside the class constructor. Inside the constructor xml event is working but all my class properties variables are not visible inside the event function.

    Even stranger, the xml-class object has not loaded my xml-file…

    class loadxmlvar.loadXMLvar {

    var xmldoc:XML;

    var statusMsg;

    // ___________________


    // The xmlfile is the URL of the file we looking for

    // The XPath represents the string to be readed. in this case flash_ims_init

    // ___________________

    public function loadXMLvar() {

    // static var xmldoc:XPathDocument = new XPathDocument;


    this.xmldoc = new XML;


    public function open(xmlfile) {

    xmldoc.ignoreWhite = true;

    xmldoc.onLoad = event_xmlfileLoaded;



    public function event_xmlfileLoaded(status:Boolean) {

    // check if we got a succesfull load

    if (status) {

    // this trace will give you undifined?!?! why?


    // document is not found,





    I getting totaly nuts of this!


Comments are closed.