| « First Nokia with Flash Lite Pre-installed - a Mass Market Model! | London MMUG - Tink and Aral on the Alphas » |
David Williams on the Flash Lite Yahoo Group asks, how do I make time limited trials in Flash Lite 1.1?
There are a few options to consider:
- Time out after a few minutes each time.
- Time out after X days and never run again.
- Lose functionality after X days or weeks.
Unfortunately it is getting late and I have work to do, so I've only got time to cover the first in that list, but I'm still writing my book on Flash Lite which is due March, and that will have detailed instructions and samples for each - end plug.
So the code for the first example is very simple, and I've included an FLA which contains a movie clip in the library that you can simply drag into your game or app to make sure it exits 3 minutes after starting up.
First up, create a new Flash document using a mobile template, and create a new movie clip, called "TrialMaker". Edit that movie clip and type the following code on frame 1:
timeout = 180; startTime = getTimer();
Next up, create a keyframe on frame 10, and add the following:
if(getTimer()-startTime > timeout*1000)
{
fscommand("quit");
}
gotoAndPlay(2);
I chose frame 10, as this creates an automatic loop, a loop that doesn't execute code all that often thus having a negligable impact on your game execution speed whilst remaining fairly accurate (which we all know is essential for Flash Lite games). You can modify the value of timeout to any number of seconds you wish, I chose 3 minutes at Davids request.
If you are lucky enough to be using Flash Lite 2, you can simply add the following code to frame 1:
setInterval(function() { fscommand("quit"); }, 180000);12 comments
Comments are closed for this post.
Follow me on Twitter
I as an artist rather than code head came up with a symbol that has nothing on for 12x60 frames then a stop frame with a message and my company logo and a quit button.
Not elegant, but it got me out of the clag. :)
This symbol is placed on top level so as when it reaches the stop frame it blocks everything else
thanks for sharing :)
thanks for sharing :)
cialis information including how to buy online at cheap prices , find out about cialis here.
viagra information including how to buy online at cheap prices , find out about viagra here.