• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

Pure Actionscript remoting with Coldfusion Components. Can this happen?

Hello,

I am coding in pure Actionscript 3.0 (not Flex, not Flash Authoring Tool), and I use Coldfusion 9 for my server-side scripting.  I am trying to directly access my CFC from the Flash runtime.  I assume the best way to do this is to use the URLLoader and URLRequest classes on a CFC with access="remote". ?  

(Is this the best way to do this?  I've heard a little about Flash Remoting, but I've also heard that it's only for Flex developers.??)

I have attached my simple code that I thought would work, but my trace statement outputs the ENTIRE .cfc code rather than just what I'm trying to return.  I'm clearly missing something.

Please help.  I just want to get the value RETURNED by the CFC, not the CFC itself. :)

Thank you.
CFC.txt
Class.txt
0
chaseivey
Asked:
chaseivey
  • 2
1 Solution
 
chaseiveyAuthor Commented:
UPDATE:::

I realized that my URLRequest object needed to begin with "http://myhostname" rather than use a relative URL reference "../../" in order for the request to happen the right way.  

However, I noticed that Coldfusion always returns in wddxpacket, which I suppose is merely XML that can be parsed by AS3 ?

Still need to know if I'm going about this the right way, or if there is a better way for AS3 to communicate with CFCs.  :)  ?
0
 
ProactivationCommented:
You could use a NetConnection like this:

import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
import mx.events.FlexEvent;

private var _gateWay:NetConnection;

protected function application1_creationCompleteHandler(event:FlexEvent):void {
	_gateWay = new NetConnection();
	_gateWay.objectEncoding = ObjectEncoding.AMF3;
	_gateWay.connect("http://www.yourURL.com/flashservices/gateway/");
	_gateWay.call("HelloWorld.SayHello", new Responder(onResult, onFault));
}

private function onResult(evt:Object):void {
	trace ("RESULT: " + evt)    
}

private function onFault(evt:Object):void {
	trace("FAULT " + evt.error);
}

Open in new window


If you compile using the Flex SDK and import mx.remoting.* then you should also be able to do it using the Flash Remoting approach, and anything else that doesn't have dependancies on the Flex display hierarchy.
0
 
chaseiveyAuthor Commented:
Thank you for your help.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now