/** * @author Matt Shaw * @url http://sf.net/projects/xmlrpcflash * http://www.osflash.org/doku.php?id=xmlrpcflash */ import com.mattism.http.xmlrpc.util.XMLRPCUtils; import com.mattism.http.xmlrpc.util.XMLRPCDataTypes; import com.mattism.http.xmlrpc.MethodCall; class com.mattism.http.xmlrpc.MethodCallImpl extends XML implements MethodCall { private var _VERSION:String = "1.0"; private var _PRODUCT:String = "MethodCallImpl"; private var _TRACE_LEVEL:Number = 3; private var _parameters:Array; private var _name:String; public function MethodCallImpl(){ this.removeParams(); this.debug("MethodCallImpl instance created. (v" + _VERSION + ")"); } public function setName( name:String ):Void { this._name=name; } public function addParam(param_value:Object,param_type:String):Void { this.debug("MethodCallImpl.addParam("+arguments+")"); this._parameters.push({type:param_type,value:param_value}); } public function removeParams( Void ):Void { this._parameters=new Array(); } public function getXml( Void ):XML { this.debug("getXml()"); var ParentNode:XMLNode = new XMLNode(); var ChildNode:XMLNode = new XMLNode(); // Create the ... root node ParentNode = this.createElement("methodCall"); this.appendChild(ParentNode); // Create the ... node ChildNode = this.createElement("methodName"); ChildNode.appendChild(this.createTextNode(this._name)); ParentNode.appendChild(ChildNode); // Create the ... node ChildNode = this.createElement("params"); ParentNode.appendChild(ChildNode); ParentNode = ChildNode; // build nodes that hold all the params this.debug("Render(): Creating the params node."); var i:Number; for (i=0; i> Begin Array"); TypeNode = this.createElement("array"); DataNode = this.createElement("data"); //for (var i:String in parameter.value) { // DataNode.appendChild(this.createParamsNode(parameter.value[i])); //} var i; //:Number for (i=0; i> Begin struct"); TypeNode = this.createElement("struct"); for (var i:String in parameter.value) { var MemberNode:XMLNode = this.createElement("member"); // add name node MemberNode.appendChild(this.createElement("name")); MemberNode.lastChild.appendChild(this.createTextNode(i)); // add value node MemberNode.appendChild(this.createElement("value")); MemberNode.lastChild.appendChild(this.createTextNode(parameter.value[i])); TypeNode.appendChild(MemberNode); } this.debug("CreateParameterNode(): << End struct"); Node.appendChild(TypeNode); return Node; } } } /*/////////////////////////////////////////////////////// fixCDATAParameter() ?: Turns a cdata parameter into a string parameter with CDATA wrapper IN: Possible CDATA parameter OUT: Same parameter, CDATA'ed is necessary ///////////////////////////////////////////////////////*/ private function fixCDATAParameter(parameter:Object):Object{ if (parameter.type==XMLRPCDataTypes.CDATA){ parameter.type=XMLRPCDataTypes.STRING; parameter.value=''; } return parameter; } public function cleanUp():Void { this.removeParams(); this.parseXML(null); } private function debug(a:Object):Void { trace(a); } }