dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Passing an Object using Flash Remoting to CF 8

Hybrid View

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    1

    Passing an Object using Flash Remoting to CF 8

    I am having difficulty sending an object from Flash to CF8. I can send simple data, arrays, and multi-dimensional arrays. However, any time I try to send an object, I get the error:

    "Unknown object type tag (17)"

    I have done a fair amount of research and I have changed the objectEncoding to AMF0, but that still hasn't helped. Does anybody have any ideas?

  2. #2
    Junior Member
    Join Date
    Jul 2008
    Posts
    14
    anybody?

  3. #3
    Junior Member
    Join Date
    May 2008
    Location
    Hawaii
    Posts
    27

    Post

    I think that it is because you are not looping. I am not sure, as I am stuggeling with flash remoting with actionscript 3.

    This connects to the flash gateway, but I can't seem to trace the function, or anything else

    Do you kknow if pending calls are still valid in actionscript 3?
    Code:
    import flash.net.*;
    
    var myservice:NetConnection = new NetConnection();
    myservice.connect("http://localhost/flashservices/gateway");
    
    
    var responder:Responder = new Responder(onResult, onFault);
    
    function onResult(responder:Object):void{
    	for(var i in responder ){
    	  trace(responder[i]);
    	}
    }
    
    function onFault(responder:Object):void{
    	for(var i in responder ){
    	  trace(responder[i]);
    	}
    
    }
    
    myservice.call("path to your cfc", responder);

  4. #4
    Junior Member
    Join Date
    Jul 2008
    Posts
    14
    We figured out that you can not pass a single structure so you need to package it in an array.

    Other than that issue it works pretty much as it is shown above. Here is our code:

    PHP Code:
    // remoteCall.as     
    // need a remoteSend for scoring
    package classes.service{
        
    import classes.bean.Test;
        
    import classes.bean.TestItem;
        
    import classes.bean.TestItemProblem;
        
    import flash.display.DisplayObject;
        
    import flash.display.DisplayObjectContainer;
        
    import classes.service.LoggerService;
        
        
    import flash.net.*;//Required for all the netConnection classes
        
    import flash.events.Event;
        
    import flash.display.MovieClip;
        

        public class 
    RemoteCall {
            private var 
    mc_preload_ani:DisplayObject;
            private var 
    parentPtr:MovieClip;
            private var 
    obj:Object;
            private var 
    myService:NetConnection;
            private var 
    responder:Responder;
            private var 
    serviceCallParam:Object;
            
            
    // this error URL is in RemoteCall.as / RemoteSend.as / ICatView.as
            
    private var request:URLRequest = new URLRequest("http://www.adobe.com" );
            
            static const 
    REMOTING_GATEWAY_ADDRESS:String "http://YourURL/flashservices/gateway/";
            static const 
    WRAPPER_CALL_SERVICE:String "model.YourScript.YourMethod";
            static const 
    QUESTION_DATA_SERVICE:String "model.YourScript.YourMethod";
            
            
    // need a var nameing refresher
            
    function RemoteCall(parentPtrParam:MovieClip ) {
                
    init(parentPtrParam);
            }


            private function 
    init(parentPtrParam:MovieClip) {
                
    //preloader image
                //mc_preload_ani = new preload_ani();
                
    parentPtr parentPtrParam;
                
    myService = new NetConnection();
                
    myService.objectEncoding=ObjectEncoding.AMF0;
                
    myService.connect(REMOTING_GATEWAY_ADDRESS);
            }
            
            public function 
    makeWrapperCall():void {
                
    // load preloading animation
                
    parentPtr.showPreloader();            
                
    responder = new Responder(onWrapperCallResult,onFault);
                
    myService.call(WRAPPER_CALL_SERVICE,responder);
            }
                
            public function 
    makeQuestionDataCallparams:Object ):void {
                
    responder = new Responder(onQuestionDataCallResult,onFault);
                
    serviceCallParam params;            
                
    LoggerService.info("makeQuestionDataCall(" serviceCallParam.itemId ")");
                
    myService.call(QUESTION_DATA_SERVICEresponderserviceCallParam.itemId);
            }
        
            
            function 
    onWrapperCallResult(obj:Object):void {
                
    LoggerService.debug("recieved onWrapperCallResult");
                
    parentPtr.testDataObj parseTestResultobj.RESULTDATA); // pushing the struct to the timeline
                
    parentPtr.hidePreloader();
                
    parentPtr.gotoAndStop("loadQuestion");
            }
            
            function 
    onQuestionDataCallResult(obj:Object):void {
                
    LoggerService.debug("recieved onQuestionDataCallResult");
                
    LoggerService.info(obj.toString());
                
    serviceCallParam.callbackFn(obj);
            }
            
            
            function 
    onFault(fault:Object) {
                
    //send them to an error page so that they can log in again.
                
    LoggerService.error("There was a problem on RemoteCall: " fault.code ":" fault.description);
                
    navigateToURL(request);
            }
            
            private function 
    parseTestResultobj:Object ):Test 
            
    {
                var 
    testBean:Test = new Test(obj.TESTIDobj.TIMESTAMPobj.SCORE);
                
                
    //loop over the test items
                
    for ( var i:uint obj.ATESTITEM.length i++ ) {
                    var 
    curTestItemData:Object obj.ATESTITEM[i];
                    
    //create a new test item
                    
    var testItem:TestItem = new TestItem(curTestItemData.ITEMCODEcurTestItemData.URL);
                
                    
    //loop over the problems in this test item
                    
    for ( var j:uint curTestItemData.ATESTITEMPROBLEM.length j++ ) {
                        var 
    curProbData curTestItemData.ATESTITEMPROBLEM[j];
                        
    //create new problem bean
                        
    var testItemProblem:TestItemProblem = new TestItemProblemcurProbData.PROBLEMCODEcurProbData.APROBLEMSKILLcurProbData.CORRECTANSWERcurProbData.USERANSWER);
                        
    //add problem to test item
                        
    testItem.addTestItemProblemtestItemProblem );
                    }
                    
    //add the item to the test
                    
    testBean.addTestItemtestItem );
                }
                
                return 
    testBean;
            }
        }


  5. #5
    Junior Member
    Join Date
    May 2008
    Location
    Hawaii
    Posts
    27
    Hi,
    This looks interesting. I will check this out for sure. I found a easy way to pass a cfc into your flash movie is:
    PHP Code:
    import flash.net.*;
    var 
    gateway:NetConnection = new NetConnection();
    var 
    responder:Responder=new Responder(onResult,onFault);

    function 
    onResult(responds:Object):void {
        
    trace("cfc result"+":"+" "+responds.toString());
    }

    function 
    onFault(responds:Object):void {
        
    //loop over the fault structure 
        
    for (var i:String in responds) {
            
    trace":" responds[i] );
        }
    }

    // name the default cf test server on this machine
    gateway.connect("http://localhost/flashservices/gateway/");

    // name of the cfc and the function
    gateway.call("cfcs.getTest.getTestConn"responder); 
    the cfc:
    PHP Code:
    <cfcomponent displayName="getTest"
      <!--- 
    Establish a Flash Remoting Connection ---> 
      <
    cffunction name="getTestConn" access="remote" returnType="string" output="true">
        <
    cfreturn "....connection successful"
       </
    cffunction
     </
    cfcomponent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center