all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

problem reading actionscript data returned


problem reading actionscript data returned enantiomer
11/18/2006 11:21:47 PM
flash actionscript: I am new to flash and am testing that remoting can interface
with my business services and objects for a project that I am
interested in. The problem is that although I can communicate with the
server on simple assembly service method calls, when i try to return an
array of objects, it says what the correct length is, but returns
"nothing" when i try to trace the values in the debugger!

The same result happens if I get the results back from an aspx page
from the FlashGateway control. Interestingly, if I return a recordset,
the data gets remoted successfully. Do custom objects need to
implement an interface like ISerializable?

Some help
would be appreciated. I am making assembly calls on my c# .net service
with flash mx. Below is my code:

Client code
----------------------
import mx.remoting.Service;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;

// fire up the output to the NetConnection debugger
mx.remoting.debug.NetDebug.initialize();

var newService = new Service("http://192.168.1.100/gateway.aspx", null,
"FlashRemoting.RemotingExample.EchoTest", null, null);

var pc:PendingCall = newService.GetPeople();
pc.responder = new RelayResponder(this, "onRemotingResult",
"onRemotingFault" );

function onRemotingResult(re:ResultEvent):Void
{
mx.remoting.debug.NetDebug.trace({level:"None", message:"There
was no
problem: " + re.result });
trace(re.result.length);
trace("re = "+re[i]);
for(var i=0; i < re.result.length; i++){
trace("event name = "+re.result[i].Name);
}//for

}

function onRemotingFault(fe:FaultEvent):Void
{
mx.remoting.debug.NetDebug.trace({level:"None", message:"There
was a
problem: " + fe.fault.faultstring });
trace(fe.fault.faultstring);

}

And the Server code
-----------------------------
using System;
using FlashGateway.IO;

namespace FlashRemoting.RemotingExample
{
///
/// Summary description for Class1.
///
public class EchoTest
{
public EchoTest()
{
//
// TODO: Add constructor logic here
//
}
public string echoString(string s)
{
s += " , hello";
return s;
}

public Person[] GetPeople()
{
Person[] people = new Person[2];
Person person = new Person();
person.Name = "Jon";
people[0] = person;
person = new Person();
person.Name = "Dave";
people[1] = person;
return people;
}
}

And here is the results I am getting from the NetConnection Debugger:

DebugId: "0"
EventType: "Result"
MovieUrl: "file:///D|/Documents and Settings/Jonathan/My
Documents/Visual Studio 2005/WebSites/RemotingTest/PumaEvents.swf"
Protocol: "http"
Source: "Client"
Time: 1163920828046
Date (object #1)
......"Sat Nov 18 23:20:28 GMT-0800 2006"
Result (object #2)
......[0]: (undefined)
......[1]: (undefined)
Re: problem reading actionscript data returned enantiomer
11/19/2006 6:26:25 PM
So, I got it and only two days wasted.

In order to pass your .Net objects to flash, they first need to be
converted to an ASObject type. This is basically just controlling how
they are serialized. Why they didn't choose to rely on ISerializable
beats me.

This document says it all:

http://livedocs.macromedia.com/flashremoting/mx/Using_Flash_Remoting_MX/usingFRNET6.htm#1178906
AddThis Social Bookmark Button