A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need help with script and conditions

  1. #1
    Junior Member
    Join Date
    Apr 2001
    Well, I've made a "birthdayscript" that return actual age to a dynamic text. This almost works but ones in a while it returns the else condition when if should been returned. Take a look at it if you will. Mathematicly it should work after testing it with a truthtable.

    myDate = new Date();
    oldmonth = new Date(10);
    oldday = new Date(7);
    oldyear = new Date(1978);
    day = new Date(myDate.getDate());
    month = new Date(myDate.getMonth());
    year = new Date(myDate.getFullYear());
    if ((oldday<=day) or (oldmonth<month)) {
    age = year-oldyear;
    } else {
    age = (year-oldyear-1);
    if ((oldday<>day) and (oldmonth<>month)) {
    grattis = "";
    } else {
    grattis = "Gratulere med dagen";

    The last condition returns a message every birthday (Happy birthday). The first one the actually age, wicth switch on every day of birth.

    Thank you for any kind of tip.


  2. #2
    Senior Member
    Join Date
    Feb 2001
    in theory aour code shoudl work. but i think it's better programmed this way:

    grattis = "";
    if ((oldday == day) && (oldmonth == month))
    grattis = "Gratulere med dagen";

    ... the message will only be displayed when the birthday is true - there's no need to check if the birthday isn't on that day.

    Hope this works for you

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