In order to use the Kongregate Client API in your Flash game when it is hosted in an iframe, you will need to pass some Kongregate-specific Flash variables into your SWF to allow the ActionScript 3 API to be loaded properly.
For best compatibility with all browsers, set your Flash AllowScriptAccess param to "always" when embedding your SWF
This function will return a URL-encoded string, which will end in "&", so you can simply add any custom Flash Variables you need onto the end of it. You must then pass these Flash Variables into your SWF. For more information on how to do this, see this link.
If you are using something like SWFObject to embed your SWF, it might be more convenient to have access to an
Object as opposed to a
String containing the Flash Variables. This allows you to enumerate the required Kongregate variables and merge them in with your own variables. You can access this object using the
flashVarsObject function as shown below:
Here is a very basic example of how to utilize the above information to pass the Kongregate Flash Variables into your SWF. Please note that this example is very crude, and it is more common to use something such as SWFObject or Adobe's tools to embed a SWF.
Once your SWF is loaded using these Flash variables, you can load and use the ActionScript 3 API normally.
Updated over 3 years ago