Tag Archives: Flash

Local playback security in FlashDevelop and Flash CS3 / CS4

I’ve seen a few people get into a pickle over this one. When you’re developing and testing locally, you need to set the ‘Local Playback Security’ setting (sometimes referred to as the ‘use network services’ option) depending on whether you wish to access local external files (e.g. XML files, or images) or some other server (e.g. your dev backend server). You can’t access both from a locally running SWF anymore, since it’s a security risk. So here’s how to set that option in Flash CS3 / CS4 or from within FlashDevelop.

How to use ExternalInterface to integrate AS3 with JavaScript

Here’s a quick snippet of code for setting up intercommunication between a SWF and JavaScript, using ExternalInterface:

import flash.external.ExternalInterface;

// Calling a JavaScript function from AS3 (with optional parameters)
if (ExternalInterface.available) ExternalInterface.call("javascriptFunction", param1, param2);

// Implementing a JavaScript callback in AS3 (flashFunction is called when JavaScript calls javascriptFunction)
if (ExternalInterface.available) ExternalInterface.addCallback("javascriptFunction", flashFunction);

Synchronising animation across multiple player instances

I’ve been asked a few times how to create effects that require multiple instances of the Flash Player on a page to remain ‘in sync’, even with user interaction. Reading and writing to cookies frequently is inefficient and resource heavy. Also, when you have more than 2 SWFs, deciding which SWF updates who becomes tricky – especially if someone decides to change or remove an instance, or an instance which you picked as ‘master’ is not loaded, for some reason.

So, I came up with this solution, using LocalConnection with a twist, which works pretty well. But, if anyone has a better method, drop it in a comment below 🙂