Wait - I had little confidence in myself. I think I figured it out with your suggestion Jesse. This seems to work - is it pretty rock solid? Seems like it works fine now, but don't know if there are any problems with this approach?
import mx.utils.Delegate; class com.icfconsulting.xml.XLoad{ public var complete:Boolean = false; public var xmlObjects:Array = new Array(); private var numFiles:Number; private var xmlFiles:Array; private var loadCount:Number=0; function XLoad(xmlFiles:Array){ this.xmlFiles = xmlFiles; this.numFiles = this.xmlFiles.length for(var i=0; i<this.numFiles; i++){ this.xmlObjects[i] = loadXML(i); } }; function loadXML(num:Number):XML{ var xmlObject = new XML(); xmlObject.ignoreWhite = true; xmlObject.loadCount = 0; xmlObject.onLoad = Delegate.create(this, loadSuccess); xmlObject.load(this.xmlFiles[num]) return xmlObject; }; function loadSuccess():Void{ this.loadCount++; trace(this.loadCount); if(this.loadCount == this.numFiles){ trace("all files loaded!"); } }; }; Jason Merrill | E-Learning Solutions | icfconsulting.com >>-----Original Message----- >>From: [EMAIL PROTECTED] [mailto:flashcoders- >>[EMAIL PROTECTED] On Behalf Of Merrill, Jason >>Sent: Friday, March 03, 2006 6:42 PM >>To: Flashcoders mailing list >>Subject: RE: [Flashcoders] Scope issues within a class >> >>Yeah - thanks, but how to do that for multiple xml files and know when >>all the files are loaded? Say you just had an array of xml files and >>then wanted to know when they had all been successfully loaded in? >> >>Thanks. >> >>Jason Merrill | E-Learning Solutions | icfconsulting.com >> >> >> >> >> >> >> >> >> >> >>>>-----Original Message----- >>>>From: [EMAIL PROTECTED] [mailto:flashcoders- >>>>[EMAIL PROTECTED] On Behalf Of JesterXL >>>>Sent: Friday, March 03, 2006 5:59 PM >>>>To: Flashcoders mailing list >>>>Subject: Re: [Flashcoders] Scope issues within a class >>>> >>>>Yeah, use Delegate for the onLoad. >>>> >>>>yourXML.onLoad = Delegate.create(this, yourLoadFunction); >>>> >>>>----- Original Message ----- >>>>From: "Merrill, Jason" <[EMAIL PROTECTED]> >>>>To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> >>>>Sent: Friday, March 03, 2006 5:52 PM >>>>Subject: [Flashcoders] Scope issues within a class >>>> >>>> >>>>I'm attempting to write a class that loads multiple XML files and >>>>broadcasts (even just to the trace window for now) when all the files >>>>are completely loaded. I'm having some trouble with scope when within >>>>the onLoad event of the XML object. Maybe going about this the wrong >>>>way. See the comments witin the code below: >>>> >>>>class com.icfconsulting.xml.XLoad{ >>>>public var complete:Boolean = false; >>>>public var xmlObjects:Array = new Array(); >>>>private var numFiles:Number; >>>>private var xmlFiles:Array; >>>>private var loadCount:Number; >>>> >>>>function XLoad(xmlFiles:Array){ >>>>this.xmlFiles = xmlFiles; >>>>this.numFiles = this.xmlFiles.length >>>>for(var i=0; i<this.numFiles; i++){ >>>>this.xmlObjects[i] = loadXML(i); >>>>} >>>>}; >>>> >>>>function loadXML(num:Number):XML{ >>>>var xmlObject = new XML(); >>>>xmlObject.ignoreWhite = true; >>>>xmlObject.loadCount = 0; >>>>xmlObject.onLoad = function(success:Boolean){ >>>>if(success){ >>>>//this works fine for the individual XML files, >>>>but... >>>>//the function on the next line never gets called because of scope >>(?): >>>>checkComplete(); >>>>//so instead tried to set a property of the class instance - the >>problem >>>>with the //next line is "this" is the XML instance, not the class - >>how >>>>to refer to the class?? >>>>this.complete = true; >>>>} >>>>} >>>>xmlObject.load(this.xmlFiles[num]) >>>>return xmlObject; >>>>}; >>>> >>>>function checkComplete():Void{ >>>>trace("hello?"); >>>>loadCount++; >>>>if(this.loadCount == this.numFiles){ >>>>trace("all files loaded!"); >>>>} >>>>} >>>> >>>>} >>>> >>>>So what would be a better approach? Or, if I am going down the right >>>>path, then how do I delegate an event when the xmlObject.onLoad has >>>>success for X number of times? >>>> >>>>Thanks for any help. >>>> >>>>Jason Merrill | E-Learning Solutions | icfconsulting.com >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>>NOTICE: >>>>This message is for the designated recipient only and may contain >>privileged >>>>or confidential information. If you have received it in error, please >>notify >>>>the sender immediately and delete the original. Any other use of this >>e-mail >>>>by you is prohibited. >>>>_______________________________________________ >>>>Flashcoders@chattyfig.figleaf.com >>>>To change your subscription options or search the archive: >>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >>>> >>>>Brought to you by Fig Leaf Software >>>>Premier Authorized Adobe Consulting and Training >>>>http://www.figleaf.com >>>>http://training.figleaf.com >>>> >>>>_______________________________________________ >>>>Flashcoders@chattyfig.figleaf.com >>>>To change your subscription options or search the archive: >>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >>>> >>>>Brought to you by Fig Leaf Software >>>>Premier Authorized Adobe Consulting and Training >>>>http://www.figleaf.com >>>>http://training.figleaf.com >>_______________________________________________ >>Flashcoders@chattyfig.figleaf.com >>To change your subscription options or search the archive: >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >>Brought to you by Fig Leaf Software >>Premier Authorized Adobe Consulting and Training >>http://www.figleaf.com >>http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com