We can save the registration information in the Windows Registry, the "isRegistered" method reads data from Windows Registry and check if it is valid.
var key = "mysample";
function isRegistered()
{
var userName = readProfile("Registration", "UserName");
var password = readProfile("Registration", "password");
if (Encryption.desEncode(key, userName) == password)
return true;
return false;
}
function register(userName, password)
{
if (Encryption.desEncode(key, userName) != password)
return false;
writeProfile("Registration", "userName", userName);
writeProfile("Registration", "password", password);
return true;
}
Insert the above codes into the "Initialize" script to make them can be accessed in the "CheckExpiry" and the "doRegister" scripts.
When the application finds that it is expired and not registered, it will jump to the "Expired" frame, in the frame, you can let the users to input their user names and passwords to register the application.
Providing the "Expired" frame has two input text boxes, associate with two variables "userName" and "password", and a "Register" button, the action for the "Register" button is
on(release)
{
FSCommand("FFish_Run", "doRegister");
}
In SWFKit, insert a "doRegister" script, and input the following code
var un = FlashPlayer.getVariable("userName");
var pw = FlashPlayer.setVariable("password");
if (!register(un, pw))
Dialogs.msgBox("invalid user name or password!");
else
{
Dialogs.msgBox("Thanks to register mysample!");
FlashPlayer.targetGotoLabel("_root", "good");
}