ClicFlic Logo

ClicFlic Logo
ClicFlic

Saturday, September 14, 2013

Embedding Active External SWFs

In some cases, you may have a complex SWF that you want to embed into a ClicFlic IMO that collects data from the user that you want to store via the ClicFlic IMO reporting system. You can now doing this using the new SWF Component Interaction Item format. 

Note that these external SWFs are linked to via a URL you must provide, rather than a embedded. This gives you more flexibility in maintaining the external SWF.

Also, external SWF interaction items only work in the Flash implementation of ClicFlic. They do not work and will be ignored by the HTML5 implementation.

Simply create a SWF Component interaction item in the interaction you wish to use, then go to advanced settings and provide the URL to the external SWF.

In order to pass data to the IMO SWF, you must do several things when creating your external SWF:

1. Allow for cross-scripting by placing the line:

Security.allowDomain(  "*" );

in your top level constructor.

2. Create a public variable  responseData in your top-level object with a line like this:

public var responseData:Object;

This object should have four defined fields, which you can update as appropriate. These are:

- responseText: String - 'This is the Response Text',
- responseCode: integer - Great than 0 means OK.
- errorCode: integer - 0 means no error
- errorText: String - any additional information concerning an error.

3. When you want to send data, like a click message or user-entered data, you must dispatch a MouseEvent.CLICK event using the loaderInfo.sharedEvents field of your top-level object, like this:

e = new MouseEvent( MouseEvent.CLICK );
loaderInfo.sharedEvents.dispatchEvent( e );

When the ClicFlic IMO receives this event, it will read the responseData variable and extract the necessary data from this object. The responseText field will be included within the responseXML for this object.

No comments:

Post a Comment