A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: expiration date

  1. #1
    Liquified
    Join Date
    Mar 2001
    Location
    Stamford, CT
    Posts
    81

    expiration date

    Hi all,

    I'm wating for a client to pay up and would like to get the money soon. They have told me the payment is in the mail but it's been over a week and I have not received anything. Anyway, I would like to set up a movie that will "expire" if the payment is not received by a certain date (considering he may lock me out of the site and I'll have no way of removing the files already uploaded). I've tried this piece of code, but it doesn't want to work:

    expiryDATE = "2/8/2003";
    myDate = new Date();
    dateTODAY = (myDate.getMonth()+"/"+myDate.getDate()+"/"+myDate.getFullYear());
    dateEXPIRE = "expiryDATE";
    if (dateTODAY >= dateEXPIRE) {
    gotoAndStop("Payment", 1);
    } else {
    gotoAndPlay("Scene 3", 1);
    }

    Any suggestion as to what I'm doing wrong? (I mean besides uploading the files before I was paid! It's a long story and they were an affiliate of my former employer.)

    Thanks,

    Liquid4012
    "Life is the crummiest book I ever read, there isn't a hook...Just a lot of cheap shots, pictures to shock, and characters an amateur would never dream up."

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Location
    Malibu
    Posts
    251
    You need to get rid of the "/"'s and treat the dates as numbers.

    code:

    // expiration date
    expiration = "282004";
    // new date object
    todaysDate = new Date();
    // day of month
    currentDate = todaysDate.getDate();
    // month of year (add 1 because this returns 0-11)
    currentMonth = todaysDate.getMonth() + 1;
    // year (4 digits)
    currentYear = todaysDate.getFullYear();
    // put them together
    current = currentMonth add currentDate add currentYear;
    // Compare dates
    if (Number(current) >= Number(expiration)) {
    // Request payment
    }else{
    // Work as normal
    }



    When you do this be sure to make your client aware of it, unless you don't want any future work from him.
    www.electricbluemonkey.com

  3. #3
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173
    You'll need to do something slightly different, actually. Writing Feb 8, 2004 as 282004 is not the best approach. In this format, January 1 of 2005 is "less than" the expiration date.

    Either write the date as YYYYMMDD, always padding out to two-digit month and day, or use milliseconds since 1/1/1970, returned by Date.UTC().

    The problem with your original code was that you were trying to compare two strings, not two numbers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center