Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts

Remoting with BlazeDS from plain vanilla Actionscript 3 class

Thursday, 21 August 2008 | Labels: , | 77 comments |

I wanted to use BlazeDS from within my plain AS3 project (no mxml or Flex, well of course I need to use the Flex remoting and rpc classes on the client). I found a number solutions on the web, unfortunatly none of them worked. After much effort I got a example almost working but I kept getting this error on the client:

TypeError: Error #1034: Type Coercion failed: cannot convert Object@13e9921 to mx.messaging.messages.ErrorMessage.

and this error on the server:

No destination with id 'null' is registered with any service.

Fortunally Peter Farland over at the Adobe product forums gave me a (rather obscure) solution:
http://www.adobeforums.com/webx/?13@618.wIQPiTpvUo4@.59b6384e/0

I thought I'd document the full solution here in case anybody else ran into the same problem.

Environment

  1. BlazeDS, the recommended turnkey installation (my file was blazeds_turnkey_3-0-0-544.zip)
  2. Flex 3 SDK
  3. Flash Develop 3
Setup

  1. Unzip the BlazeDS zip file and start the sample DB and then Tomcat as the standard instructions say.
  2. Check the sample 3 in the "Take the test run", you should get a grid up with a load of camera data.
  3. Go to the [BlazeDS install directory]\tomcat\webapps\ROOT\ and copy the crossdomain.xml file there
  4. Now open you AS3 dev enviroment, I used Flash Develope, but Flex builder, Flash IDE or FDT will do.
  5. Create a project and copy the Main.as source file at the end of this post as the main class.
  6. Check the url in the code is correct for you
  7. Run it, you should see a load of trace. In that trace there you should see the same information as when you ran example.
My next post will be about configuring your own services and classes on the server, and maybe a more general solution...

Files
Main.as
crossdomain.xml