Andreas Rønning wrote:
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);
}
}
It is amazing how we can turn back to this first-grade example of
understanding scoping in ActionScript almost daily.
But I'll go with the flow and return the most common answer (that I also
personally use):
class ParseXML{
private var xmlDoc:XML;
private function handleXML(){
trace(this);
}
function ParseXML(url:String):Void {
xmlDoc = new XML();
xmlDoc.ignoreWhite = true;
xmlDoc.onLoad = mx.utils.Delegate.create(this, handleXML);
xmlDoc.load(url);
}
private function toString():String {
return "i am not the xmlDoc";
}
}
The issue is, that you have to make the xmlDoc call the
handleXML-function with containing class as the activating scope. That
can only be done via either hacking the XML-class or creating a special
function, that will make the proper invocation of the proper function in
the proper scope!
:)
--
Morten Barklund - Information Architect - Shockwaved
Gothersgade 49, 4th floor - DK-1123 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders