gskinner.com: gBlog: FlashMX 2004 source code, news, reviews and opinions
Back to gBlog Main gskinner.com website: source code, portfolio, etc. contact Grant Skinner

Syndication
RSS 1.0
RSS 2.0


Subscribe
Enter your email address to be notified when posts are added.

Search

Resources
Conference Session Notes

Flash Blogs
Waxpraxis
Philterblog
W3Blog
Jonas Galvez
Josh Dura
Quasimondo
Flashguru
Sean Voisen
Colin Moock
Flazoom
Greg Burch
Pope De Flash
Peter Hall
Glyn Thomas
actionscript.com
Princess Pegg


Aggregators
Flog
FullAsAGoog
MXNA
Hall of Justhese


« OOP4AS#3: Constructors | Back to Main | Korean translation of OOP4AS2 »

September 14, 2003


IMPORTANT NOTE: This is an old archive. It is only here to support outdated external links. To view the updated version of this archive, please go to the blog index, and search for the title of this document using the search form.

Important note on AS2 properties
Posted by Grant
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.

Posted @ 11:47 AM by Grant | TrackBack


Comments

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

Posted by: Brajeshwar at October 9, 2003 11:09 PM

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.statusMsg='idle';
this.xmldoc = new XML;
}

public function open(xmlfile) {
xmldoc.ignoreWhite = true;
xmldoc.onLoad = event_xmlfileLoaded;
xmldoc.load(xmlfile);

}

public function event_xmlfileLoaded(status:Boolean) {
// check if we got a succesfull load
if (status) {
// this trace will give you undifined?!?! why?
trace(statusMsg);
// document is not found,
trace(xmldoc);
}
}
}

I getting totaly nuts of this!
Jan

Posted by: Bliki at August 30, 2004 08:12 AM

Hosting by NetKeepers.ca | Powered by Movable Type 2.661
The text content of this blog is licensed under a Creative Commons License. Graphics are ©2003 Grant Skinner.