- Home /
Help with networking in flash
Networking is not supported when you build it to flash. Is there others way to do networking with flash? I have an experience with PlayerIO, Can i write an external actionscript to handle this? And how can it communicate with my unity flash build?
Answer by catburton · Jul 09, 2012 at 02:05 PM
Depending on what you want to achieve, you could communicate with PlayerIO using WWW/WWWForm, which are supported for Flash export: http://docs.unity3d.com/Documentation/Manual/flash-whatssupported.html
Alternatively, you could write native AS3 code for your networking layer when exporting to Flash. To do this, you could either use AS3 classes in your Unity project or you could create an AS3 wrapper SWF. Note that if you do write your networking code in AS3, it would then only work in Flash export. An example of how to use AS3 code within your unity project is here: http://docs.unity3d.com/Documentation/Manual/flashexamples-supplyingdata.html
This shows how to supply data between AS3 and C#/JS, but should give you a good starting point and show you how to set up some basic classes. There are other examples in that Flash area of the documentation which should also help.
An example of how to create a wrapper swf and have it communicate with your unity content is here: http://forum.unity3d.com/threads/128057-Flash-Simple-AS3-Bridge-Demo-Loading-textures-from-web.
There are a few different options there, but hopefully one of those will be suitable for your project.
Answer by Noxres · Jul 11, 2012 at 06:36 AM
Hi Cat,
thanks for your reply. We got the communication between Flash and Unity working as in http://docs.unity3d.com/Documentation/Manual/flashexamples-supplyingdata.html But now Player IOs API is asking for the flash stage object and will not work without passing in the correct one from Unity. It seems possible to fix that through preloading as in http://forum.unity3d.com/threads/116650-UnityShared.swc-Communicating-between-Unity-Flash-Content-and-AS3./page6 But then the communication part doesnt work anymore :( Is there maybe a complete example with a small chat or similar in Unity exported to Flash and working through some serverside service like PlayerIO or Photon that you know of?
Would be great if you could help me with these questions too? http://answers.unity3d.com/questions/282635/how-can-i-sent-stage-from-unity-to-other-actionscr.html
Answer by catburton · Jul 11, 2012 at 11:25 AM
I don't have any examples of using flash export with PlayerIO/Photon at present. If you need to supply the stage to PlayerIO, take a look at this which shows how the stage can be accessed within your Unity project. Perhaps you can work around your issues this way:
http://docs.unity3d.com/Documentation/Manual/flashexamples-accessingthestage.html