On 10/31/05, Andreas Rønning <[EMAIL PROTECTED]> wrote: > > > 2. What the hell is going on with "this" here > > class ParseXML{ > private var xmlDoc:XML; > private function handleXML(){ > trace(this); > } > function ParseXML(url:String){ > xmlDoc = new XML(); > xmlDoc.ignoreWhite = true; > xmlDoc.onLoad = handleXML; > xmlDoc.load(url); > } > } > > "trace this" in this case traces out the xml doc. Is this because onLoad > = handleXML declares the scope of handleXML as being the xmlDoc? > Sometimes the onLoad = functionReference; syntax weirds me out. I tend > to go for the onLoad = function(){ more specific functionality here } > method >
Yes, you're right - when handleXML is executed, it takes its scope as the xmlDoc. This is something that is altered, I believe, in AS3. For a lot more info on this behaviour, and how to cope with it, do an archive search on Delegate - or look at the wiki here: http://osflash.org/flashcoders/as2 HTH, Ian _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders