-
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?
-
-
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);
-
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 makeQuestionDataCall( params:Object ):void {
responder = new Responder(onQuestionDataCallResult,onFault);
serviceCallParam = params;
LoggerService.info("makeQuestionDataCall(" + serviceCallParam.itemId + ")");
myService.call(QUESTION_DATA_SERVICE, responder, serviceCallParam.itemId);
}
function onWrapperCallResult(obj:Object):void {
LoggerService.debug("recieved onWrapperCallResult");
parentPtr.testDataObj = parseTestResult( obj.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 parseTestResult( obj:Object ):Test
{
var testBean:Test = new Test(obj.TESTID, obj.TIMESTAMP, obj.SCORE);
//loop over the test items
for ( var i:uint = 0 ; i < obj.ATESTITEM.length ; i++ ) {
var curTestItemData:Object = obj.ATESTITEM[i];
//create a new test item
var testItem:TestItem = new TestItem(curTestItemData.ITEMCODE, curTestItemData.URL);
//loop over the problems in this test item
for ( var j:uint = 0 ; j < curTestItemData.ATESTITEMPROBLEM.length ; j++ ) {
var curProbData = curTestItemData.ATESTITEMPROBLEM[j];
//create new problem bean
var testItemProblem:TestItemProblem = new TestItemProblem( curProbData.PROBLEMCODE, curProbData.APROBLEMSKILL, curProbData.CORRECTANSWER, curProbData.USERANSWER);
//add problem to test item
testItem.addTestItemProblem( testItemProblem );
}
//add the item to the test
testBean.addTestItem( testItem );
}
return testBean;
}
}
}
-
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( i + ":" + 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|