Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-07-2005, 06:12 AM   #1
keith30
Registered User
 
Join Date: Nov 2005
Posts: 51
Default One Day Expiration

How would I modify this source if I wanted to have a one day then expire?
I would like the source to use the time and/or date the swf was launched and count down to one work for one day.

var start = new Date(2003, 1, 1);
// set start equal to 11/1/2003 (Jan = 0)
var end = new Date(2004, 0, 15);
// set end equal to 1/15/2004; do not put zeros in front of numbers
if (now
// if date is before start, then they're trying to cheat us, so give error message
trace("If you're seeing this then the now is before the START date, meaning they've set the clock back too far.");
trace("The START date is:");
trace(start);
trace("Today's date (now) is set at:");
trace(now);
_root.gotoAndStop(31);
} else if (now>end) {
// if date is after end, then go to end
trace("If you're seeing this then the now is before the END date");
trace("The END date is:");
trace(end);
trace("Today's date (now) is set at:");
trace(now);
_root.gotoAndStop(31);
} else {
trace("Everything is hunky-dorey, let's go!");
play();
}
stop();
keith30 is offline   Reply With Quote
Old 11-08-2005, 02:34 AM   #2
keith30
Registered User
 
Join Date: Nov 2005
Posts: 51
Default

Here is what I have so far.
Can anyone help me?

MC "DateCheck"

Inside DateCheck timeline
Keyframe1
--------------------------------------
// This actionscript is used to see if the user has set the date back
// on their computer.
D4XSO.data.datelastaccessed = new Date();
// Opens the shared object called "datesharedobject.sol".
D4XSO = sharedobject.getLocal("datesharedobject");
// Set "now" equal to the date on the users computer
var now = new Date();
if (now< D4XSO.data.datelastaccessed) {
// If the computer date (now) is less than the date last accessed,
// then the date has probably been set backwards on the users computer,
// so set "now" forward to that last accessed date so they can't
// access the course.
var now = D4XSO.data.datelastaccessed;
trace("Today's date (now) is being set to the datesharedobject date, which means the computer was set back; =");
trace (D4XSO.data.datelastaccessed);
trace ("Which should equal what now has been set to, which is:");
trace (now);
// Else if the computer date (now) is greater than the last date accessed,
// then all is right with the world, so go ahead and write that date
// back to the shared object as the date last accessed.
} else {
D4XSO.data.datelastaccessed = now;
D4XSO.flush();
trace("The datesharedobject date is being updated to today's date =");
trace(D4XSO.data.datelastaccessed);
}



Keyframe 22
---------------------------------------
var start = new Date(2003, 1, 1);
// set start equal to 11/1/2003 (Jan = 0)
var end = new Date(2004, 0, 15);
// set end equal to 1/15/2004; do not put zeros in front of numbers
if (now<start) {
// if date is before start, then they're trying to cheat us, so give error message
trace("If you're seeing this then the now is before the START date, meaning they've set the clock back too far.");
trace("The START date is:");
trace(start);
trace("Today's date (now) is set at:");
trace(now);
_root.gotoAndStop(31);
} else if (now>end) {
// if date is after end, then go to end
trace("If you're seeing this then the now is before the END date");
trace("The END date is:");
trace(end);
trace("Today's date (now) is set at:");
trace(now);
_root.gotoAndStop(31);
} else {
trace("Everything is hunky-dorey, let's go!");
play();
}
stop();
keith30 is offline   Reply With Quote
Old 11-08-2005, 06:54 AM   #3
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

The only thing i can think of (kind of) and it isn't very secure, it to use Date(); send the date the swf played to an SharedObjects(); on the swf's load, always check the original date in the SharedObject's against the current Date();

Once again, the is NOT secure at all. A better solution would be to use PHP and a database.

Good luck.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 11-08-2005, 07:00 AM   #4
keith30
Registered User
 
Join Date: Nov 2005
Posts: 51
Default

I could not use php and a database if it is used on Pocket PC.
keith30 is offline   Reply With Quote
Old 11-08-2005, 07:01 AM   #5
keith30
Registered User
 
Join Date: Nov 2005
Posts: 51
Default

php and database would work for the standanlone projector files for desktop versions? do you have any samples?
keith30 is offline   Reply With Quote
Old 11-08-2005, 04:37 PM   #6
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

Only if the swf. is on the internet.

stand-a-lone, I'm not sure it can be done securely.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 11-23-2005, 08:41 AM   #7
keith30
Registered User
 
Join Date: Nov 2005
Posts: 51
Default

I'm working on some new code to have my movie expire 24(one day) after the swf files in launched.

Need some help and feedback.
Enclosed is the code.
I'm using this on Pocket PC and Mac projector.



Frame 1 Layer 1
----------------------------------------------------------------
function isExpired(cookiename, lifespan) {
var so = SharedObject.getLocal(cookiename);
var now_date = new Date();
//current date in seconds from midnight January 1, 1970
var now = Math.floor(now_date.getTime()/1000);
//if it hasn't been set yet, declare it
if (so.data.dateFirstAccessed == undefined) {
trace("created "+cookiename+".sol");
so.data.dateFirstAccessed = now;
so.data.dateLastAccessed = now;
so.data.expired = false;
}
//if the date has been set back
if (now<so.data.dateLastAccessed || now<so.data.dateFirstAccessed) {
//trace("now<so.data.dateLastAccessed");
so.data.expired = true;
}
//if it has expired naturally
if (so.data.dateFirstAccessed+lifespan<now) {
//trace("so.data.dateFirstAccessed+lifespan<now");
so.data.expired = true;
}
//trace(so.data.dateFirstAccessed);
//trace(now);
//trace(so.data.dateLastAccessed-so.data.dateFirstAccessed);
if (!so.data.expired) {
so.data.dateLastAccessed = now;
return false;
} else {
return true;
}
}
//check for expiration
function checkExpiration(cookiename, lifespan) {
if (isExpired(cookiename, lifespan)) {
//clear the checkInterval loop
clearInterval(_root.checkInterval);
//just to make sure that the expired function isnt called more than once
if (!_global.expired) {
expired();
}
_global.expired = true;
} else {
//the cookie is still active
trace("still good");
}
}
//expiration function
function expired() {
//what to do when the cookie expires
trace("expired");
gotoAndStop(2);

}



Frame 1 Layer 2
----------------------------------------------------------------
//60 second lifespan for the cookie
var lifespan = 60;
var cookiename = "trialperiod";
gotoAndStop(3);

//call initial check/set cookie
checkExpiration(cookiename, lifespan);
//this loop checks every second if the cookie has expired
var checkInterval = setInterval(_root, "checkExpiration", 1000, cookiename, lifespan);


Frame 2 Layer 1
----------------------------------------------------------------
Keyframe labeled "expired"

Frame 3 Layer 1
----------------------------------------------------------------
Keyframe labeled "trialperiod"
keith30 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:11 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.