/ Published in: ActionScript 3
Use this if you need to make "trial period" to your app with Shared Objects. It is veri simple to use:
if(Validator.isActive(0,0,1)){ trace("ENTER"); } else { trace("YOUR DEMO IS OVER"); }
this demo will be active only 1 minute. Pass the validor Validator.isActive(days,hours,minutes) number of days, hours and minutes and it will return boolean.
Expand |
Embed | Plain Text
package { import flash.events.EventDispatcher; import flash.net.SharedObject; public class Validator extends EventDispatcher { public static var _active:Boolean; public static var _data:SharedObject; public static var _currentDate:Date; public static var _expireDate:Date; public function Validator() { // constructor code } public static function isActive(days:Number=0, hours:Number = 0, minute:Number = 0):Boolean{ _data = SharedObject.getLocal("exp_date"); _currentDate = new Date(); if(_data.data.expireDate == undefined){ _expireDate = new Date(_currentDate.fullYear, _currentDate.month, _currentDate.date + days, _currentDate.hours + hours, _currentDate.minutes + minute); _data.data.expireDate = _expireDate; _active = true; } else { _expireDate = _data.data.expireDate; trace("Current date : " + _currentDate); trace("Expiring date: " + _expireDate); if(_currentDate.getTime() <= _expireDate.getTime()){ _active = true; } else { _active = false; } } return _active; } }//end }
You need to login to post a comment.
