AW: [mtasc] ** MTASC v1.04 **

Sönke Rohde rohde at rivavx.com
Thu Apr 14 11:03:58 CEST 2005


> 
> > The new boolean behaviour doesn't allow if(array.length) 
> anymore, right?
> 
> it should, since only && and || return type is changed. So if 
> was already accepting not-boolean values.
> 

Great! And now my xmlutils-class compiles with typed return-type:

class com.rivavx.utils.XMLUtils {
	private function XMLUtils(){
		// only static usage
	}
	
	public static function
loadXML(callTarget:Object,callFunc:Function,path:String):Void{
		var x:XML = new XML();
		x.ignoreWhite = true;
		x.onLoad = function(b:Boolean):Void{
			callFunc.call(callTarget,b,this);
		}
		x.load(path);
	}
	
	public static function byName(node:XMLNode,nodeName:String):XMLNode{
		if(node == null){
			return null;
		}
		if (node.nodeName == nodeName){
			return node;
		}
		return XMLUtils.byName(node.firstChild,nodeName)
			||  XMLUtils.byName(node.nextSibling,nodeName)
			|| null;
	}
	
	public static function
byValue(node:XMLNode,nodeName:String,attrName:String,attrValue:Object):XMLNo
de{
		if(node == null){
			return null;
		}
		if(node.nodeName == nodeName && node.attributes[attrName] ==
attrValue)return node;
		return
XMLUtils.byValue(node.firstChild,nodeName,attrName,attrValue)
			||
XMLUtils.byValue(node.nextSibling,nodeName,attrName,attrValue)
			|| null;
	}
}

Cheers,
Sönke





More information about the mtasc mailing list