Why? haha, sorry, but to me it looks like you just added var owner = this just to avoid putting trace(this) for no reason other than avoiding to use "this". What's the specific reason you did that? I'm guessing you're smarter than me :)

- Andreas

Cedric Muller wrote:



this is logical: you assign handleXML function to 'xmlDoc.onLoad' handler which means that 'handleXML' belongs to xmlDoc from now on ...

In such cases, I do the following:

class ParseXML{
   private var xmlDoc:XML;

   private function handleXML(){
       trace(owner);
   }
   function ParseXML(url:String){
       var owner = this;
       xmlDoc = new XML();
       xmlDoc.ignoreWhite = true;
       xmlDoc.onLoad = handleXML;
       xmlDoc.load(url);
   }
}

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


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to