« Return to Thread: Typed Objects from AS2 to .NET Assembly
by Ed Haack
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View in Thread
Thank you for your responses, and I have spent the last few
days pouring over the docs, and what I’m trying to do is send a custom
class object FROM Actionscript (via Flash 8/AS2) to a .NET Assembly (2.0). Rather
than talk theory, here’s my code:
AS2 Flash, Sample App – on the frame:
import
mx.remoting.Service;
import
mx.remoting.PendingCall;
import
mx.rpc.RelayResponder;
import
mx.rpc.ResultEvent;
import
Fluorine.Stuff;
Object.registerClass("Fluorine.Stuff",
Fluorine.Stuff);
var
stuff:Stuff = new Stuff();
stuff.Name
= "Ed";
var
remotingService:Service = new Service('http://localhost/fluorine/gateway.aspx',
null, 'Fluorine.FlashRemoting');
var
pc:PendingCall = remotingService.Hello(stuff);
pc.responder
= new RelayResponder(_root, "FlashRemoting_onSuccess",
"FlashRemoting_onFault");
function
FlashRemoting_onFault(fault)
{
trace("Error:
" + fault.fault.faultstring);
}
function
FlashRemoting_onSuccess(re:ResultEvent)
{
trace("Success!
: " + re.result);
}
============================
AS2
Custom/Object Class:
class
Fluorine.Stuff
{
private
var _name:String;
public
function get Name():String {return _name;}
public
function set Name(param_name:String):Void {_name = param_name;}
public
function Stuff(){}
}
============================
C#
Remoting Reception Class:
using System;
namespace Fluorine
{
public
class FlashRemoting
{
public string Hello(Stuff s)
{
return s.Name;
}
}
}
============================
C#
Custom/Object Class:
using System;
namespace Fluorine
{
public
class Stuff
{
private string _name;
public string Name
{
get { return
_name; }
set { _name = value;
}
}
public Stuff() {}
}
}
============================
Web.config:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true" />
<authentication mode="Windows" />
<httpModules>
<add name="FluorineGateway" type="com.TheSilentGroup.Fluorine.FluorineGateway,
com.TheSilentGroup.Fluorine"/>
</httpModules>
</system.web>
</configuration>
The
result is: “Success! : null”
Some
notes here…
Both
the AS and C# custom objects reside in the same namespace/package location.
Debugging
from the Visual Studio side, the name of the property come thru (both private and
public: _name and Name), but the value is null, on both.
Now,
with Macromedia’s Remoting the C# side would expect the type
“ASObject” and use reflection, then convert to the custom object.
I’m assuming this is done within Fluorine via the “classMappings.”
I’m
beginning to think just sending primitives is the way to go, because when I
send an object, or strings, the remoting works as documented.
(BTW:
I’m not using Flex… flash.net.registerClassAlias doesn’t
apply here)
Please,
give this a try, and see if you don’t get the same results I have.
Any
insight would be very much appreciated… thanks folks
« Return to Thread: Typed Objects from AS2 to .NET Assembly
| Free Forum Powered by Nabble | Forum Help |