SWF Protection Compatibility Issues

Basically SWF Protection works for all SWF files, but it may have compatibility issues in some situations.

After protection, the SWF file does not load external image, SWF and XML files.

After protection, the address of the SWF file will be changed, and the address relative to the SWF file will also be changed. If you are using a relative file address in your Flash design, it may not work anymore.

For example, if you are using a sentence like this:

var myfile = "config.xml";

In ActionScript 2, before protection, this file will address to "config.xml" in the same folder as your SWF file. But after protection, it will not work.

To fix this problem, in the HTML codes, you can set up the attribute "base", which specifies the base directory or URL used in resolving all relative path statements in the Flash file.

You need to use an absolute address as the base URL, for example:

http://www.yoursite.com/xmlfolder/

An example HTML codes are as following:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="300" height="120">
<param name="movie" value="flash.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="transparent">
<param name="base" value="http://www.yoursite.com/xmlfolder/">
<embed src="flash.swf"
quality="high"
type="application/x-shockwave-flash"
WMODE="transparent"
width="300"
height="120"
base="http://www.yoursite.com/xmlfolder/"
pluginspage="http://www.macromedia.com/go/getflashplayer"
allowScriptAccess="always" />
</object>

You can also change your Flash codes to fix this problem. In the Flash codes, you can get the full URL address of your SWF file, then calculate the full URL address of the external file.

The ActionScript 2 codes are as following:

function getSWFFilePath()
{
var pathURL = _root._url;
var suffixPos = pathURL.indexOf("/[[DYNAMIC]]/");
var resultURL = (suffixPos > 0)? pathURL.substr(0, suffixPos) : pathURL;
suffixPos = resultURL.lastIndexOf("/");
resultURL = (suffixPos > 0) ? resultURL.substr(0, suffixPos) : resultURL;
resultURL = resultURL + "/";
return resultURL;
}
var myfile = getSWFFilePath() + "config.xml";

In ActionScript 3, the relative folder is related to the container HTML file, so basically, it works fine. The only exception is when you loads a video file with Video class, the relative folder is related to the SWF file. In this case, you need to use Flash codes to calculate the full URL address of the video file.

The ActionScript 3 codes are as following:

function getSWFFilePath()
{
var pathURL:String = stage.loaderInfo.loaderURL;
var suffixPos:int = pathURL.indexOf("/[[DYNAMIC]]/");
var resultURL:String = (suffixPos > 0)? pathURL.substr(0, suffixPos) : pathURL;
suffixPos = resultURL.lastIndexOf("/");
resultURL = (suffixPos > 0) ? resultURL.substr(0, suffixPos) : resultURL;
resultURL = resultURL + "/";
return resultURL;
}
var myfile = getSWFFilePath() + "myvideo.mp4";


After protection, my SWF file does not read parameters from FlashVars.

To get FlashVars parameters, we usually use the scripts as following:

var paramObj :Object = LoaderInfo(this.loaderInfo).parameters;

You need to change the scripts to:

var paramObj :Object = LoaderInfo(this.stage.loaderInfo).parameters;


clickTAG of ActionScript2 SWF file

SWF Protection is ActionScript 3 based, after protection, the SWF file will be converted to an ActionScript 3 based SWF file, some functions in ActionScript 2 will not work very well.

To make clickTAG of AS2 working with SWF Protection:

1. When designing the Flash file, the AS2 code of getURL should be as following:

getURL(_root.clickTAG, "_blank");

The clickTAG must be an attribute of _root, the following two scripts will NOT work:

getURL(clickTAG, "_blank");

getURL(_level0.clickTAG, "_blank");

2. In the HTML codes embedding the Flash file, you can not use FlashVars for the clickTAG, you need to directly add the clickTAG value to the end of filename, you also need to add an unused extra parameter to the end of the filename. In the following example, the clickTAG value is http://www.google.com, we also add an extra parameter random=123.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="300" height="120">
<param name="movie" value="flash.swf?clickTAG=http://www.google.com&random=123" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="transparent">
<embed src="flash.swf?clickTAG=http://www.google.com&random=123"
quality="high"
type="application/x-shockwave-flash"
WMODE="transparent"
width="300"
height="120"
pluginspage="http://www.macromedia.com/go/getflashplayer"
allowScriptAccess="always" />
</object>