AS3 Flash, Flex and Unity3D Browser Communication and Scripting with Javascript

I am working with lots of content now that is flash and unity3d in game development for the web, and occasionally systems built in flash, javascript or other have to communicate with Unity3D and vice versa.  You can do this from the server side (WWW/WWWForm class or sockets) OR you can also communicate client side for many things such as sending name value pairs or variables into Unity3D, Flash or the javascript in page as needed. There are some great tools like UnityObject that is like swfobject (only you have to update it to work with latest browsers) that make this more simple to send in params and messages. The same can be applied to Silverlight. It is pretty simple all in all but having a sample to start with is good with all these technologies.

Paul Tondeur threw togetother a little sample that shows how you can integrate Unity3D, Flash and javascript in the page fairly simply with lots of great demos.  It really is just about passing parameters around into the objects from javascript, then within Flash calling ExternalInterface to call external javascript or within Unity3D calling Application.ExternalCall.

//Flash adding callback for javascript code
ExternalInterface.addCallback("functionNameInBrowser", functionNameInFlash );
//Unity3D calling javascript code
Application.ExternalCall("javascriptFunction", "Parameter1");

Nothing too tasking but if you want to see samples of this working together from flash, flex, javascript, unity3d then check it out. Zip on over to Paul’s site to grab the files and more demos and samples. All examples are bundled in one download, which includes all the Unity3D, Flash, Flex, Actionscript and Javascript files.

Here’s some demos

Tags: , , , , , , , , , , , , , , , ,

  • http://www.paultondeur.com Paul Tondeur

    Hi Ryan,

    Thanks for giving attention to my blogpost! We’re currently working on something for Unity3D which is very awesome from a technology point of view. Hope to post some demo’s about that soon.

    Paul

  • http://drawk.com drawk

    Paul, look forward to it. The flash < -> unity3d demo was pretty sweet almost like a 3d editor could be, taking advantage of flash for gui but unity for rendering.

  • Pingback: Unity3D vs Flash Or Not | diamondTearz