views:

336

answers:

2

Is it possible to call a web service from within Flash (using AS3)? Or is the best idea to put the flash movieclip in a Flex container and use the Flex Libraries?

To be clear, when I say within Flash, I mean within the Flash CS4, AS3 programming environment.

+2  A: 

It's perfectly possible to call a JSON-returning RESTful URL from your Flash application. I do it all the time :-)

Just format a standard request using any of the RPC mechanisms (UrlLoader, HttpService) and decode the returned JSON text using the JSON serializer in as3corelib.

Vinay Sajip
Sorry Vinay - maybe not clear... I meant from within a flash application. Maybe there's a way of including the relvatn flex libraries?
dan
Actually, I'm 99% sure he meant Flash; I've done it from a Flash application, too, and the method is the same as a Flex application.
Michael Todd
You can use HTTPService and as3corelib together in flash to do this. URLLoader would work in place of HTTPService if you want too
Sean Clark Hess
How would you access HTTPService from the Flash environment - isn't this a Flex Library?
dan
+1  A: 

You could try as3httpclientlib and as3corelib has JSON serialization.

Brandon