[> AmfPHP – ServiceHelper <]

Category : [> Coding <] · (1) Comment · by 25th October 2015

vdd

This is a tiny amfphp Service Helper Class for the Flash IDE you can Input these Parameters :

GATEWAY () / The AmfPHP Gateway , METHODE() / The Service Call , QueryString () / If it is a Read or a Write Methode ,a Array of Arguments , the Container Array / in the Service Helper Class its called “DataVault”.

for Example :

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import mat3d.remoting.*;
var myContainerArray:Array = [];
var myBlindArray =[];
function onResult(e$:EventObject):void
{
 for(var a:Number = 0; a<myContainerArray.length() ;a++) {
    //** --do this and that with the Data arrived in the Container Array-- **//
  }
}
var myServiceCall = new ServiceHelper("http://localhost/amfphp/gateway.php","AmfPhpService.execute()","READ",myBlindArray,myContainerArray);
myServiceCall.addEventListener("onServiceResult",onResult);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @author Matthias Bode / mat3d 08/2011
*/
package mat3d.remoting {
    import flash.net.NetConnection;
    import flash.net.ObjectEncoding;
    import flash.net.Responder;

    import mat3d.remoting.vo.ItemVO;

    import flash.events.*;

    class ServiceHelper extends EventDispatcher {
        private var myConnection : NetConnection;
        private var myGateway : String;
        private var myMethod : String;
        private var myQuery : String;
        private var myArgs : Array;
        private var dataVault : Array;

        public function ServiceHelper(gtw : String,Meth : String,Query : String,Args : Array,Cont : Array) {
            myGateway = gtw;
            myMethod = Meth;
            myQuery = Query;
            myArgs = Args;
            dataVault = Cont;
            switch(myQuery) {
                case "READ":
                    myConnection = new NetConnection();
                    myConnection.connect(myGateway);
                    myConnection.call(myMethod, new Responder(onResult, onFault), 1);
                    break;
                case "WRITE":
                    myConnection = new NetConnection();
                    myConnection.connect(myGateway);
                    myConnection.call(myMethod, new Responder(onResult, onFault), myArgs[0], myArgs[1]);
                    break;
            }
        }

        private function onResult(eventObject : Object) : void {
            switch(myQuery) {
                case "READ":
                    for(var i:Object in eventObject) {
                        var myDataObject = new Object();
                        myDataObject.data = eventObject[i].myData;
                        myDataObject.text = eventObject[i].myText;
                        dataVault.push(myDataObject);
                    }
                    break;
                case "WRITE":
                    break;
            }

            this.dispatchEvent(new Event("onServiceResult"));
        }

        private function onFault(eventObject : Object) : void {
            trace(eventObject.Fault);
        }

        public override function toString() : String {
            return "mat3d.remoting.GetService";
        }
    }
}
/**
 * @author Matthias Bode / mat3d 08/2011
*/
package mat3d.remoting.vo {
    public class ItemVO {
        public var myData : String;
        public var myText : String;
    }
}



(1) Comment

BrianBaw
7 years ago · Reply

I am amazed. I don’t think I know anyone who knows just as much about the topic. You need to make a career of it, really, awesome blog
http://svetfitness.sk/blog/custom-essay-writing-order-your-essay-today-1305/

Leave a Reply

Your email address will not be published. Required fields are marked *