How to set the trial period for SWF file?
This step-by-step tutorial will teach you how to set the trial period for swf file.
1) Let's consider a simple example to show the implementation of trial period detector. Open any flash document, select appropriate frame and open the Action Script Panel (F9). Then enter the following code inside the actions panel:
function trialDetector():void {
const yyyy:Number = 2008; // year
const mmmm:Number = 0; // month-1 ( 0 (January), ... 11 (December))
const dddd:Number = 1; // day of month (1,2,...,30,31)
var expirationDate:Date = new Date(yyyy,mmmm,dddd);
var currentDate:Date = new Date();
if (currentDate > expirationDate){
// expiration has been detected
for(;;); // use appropriate action here, for example - infinite loop to stop movie clip
}
}
trialDetector();
2) Test your movie (Ctrl+Enter). You should see the "freezing" movie.
3) Don't forget to change values for yyyy,mmmm and dddd (in this example expiration date is equal to Jan 1 2008). Also change the function name - use something abstract instead of "trialDetector" to camouflage designation of this function.
4) Is this method secure? Unfortunately, answer is NO. There are a lot of flash decompilers. You can use the trial version of Sothink flash decompiler to understand how easy anyone can remove trial restriction and steal your flash work.
As you can see decompiler extracts ActionScript code from swf file in readable format. Moreover this decompiler can convert a swf file to fla format and an intruder can change source code to remove trial restriction.
5) If you need more secure protection you can use SwfShield.
This online tool protects swf files from being stolen.
Click "ProtectSWF" to login as guest without registration.
6) SwfShield is as easy as 1-2-3. Set desired trial period and click Build protected swf button. Select swf file to be protected, then enter name for protected file. That is all.
7) Let's run flash decompiler again and examine the content of protected swf file.
There are no original shapes, sounds etc. The original content is encrypted and hidden. The first decrypting layer is visible only.
8) You learnt two methods of protecting swf files against unauthorized use. The first one is free but everyone familiar with flash decompilers can easily overpass this approach. The second method is not free but it uses sophisticated encryption and protects complete swf file against decompilation.