Remoting with BlazeDS from plain vanilla Actionscript 3 class
Thursday 21 August 2008 | Labels: Actionscript, Flex | 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
- BlazeDS, the recommended turnkey installation (my file was blazeds_turnkey_3-0-0-544.zip)
- Flex 3 SDK
- Flash Develop 3
- Unzip the BlazeDS zip file and start the sample DB and then Tomcat as the standard instructions say.
- Check the sample 3 in the "Take the test run", you should get a grid up with a load of camera data.
- Go to the [BlazeDS install directory]\tomcat\webapps\ROOT\ and copy the crossdomain.xml file there
- Now open you AS3 dev enviroment, I used Flash Develope, but Flex builder, Flash IDE or FDT will do.
- Create a project and copy the Main.as source file at the end of this post as the main class.
- Check the url in the code is correct for you
- Run it, you should see a load of trace. In that trace there you should see the same information as when you ran example.
Files
Main.as
crossdomain.xml