A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: What am i doing wrong.....?????

  1. #1
    Senior Member
    Join Date
    Feb 2001
    Posts
    114
    Hello pplz,

    Here i am generating some sort of count down based upon a fixed date (lets say may 15th, as used in the code below)

    If i can still do some calculating i should get a result somewhere (counted from this post's entry date March 22) around the 55, but when running this script the result displayed in my swf doesn't go further than 39

    is there anyone in the house that can tell me what goes wrong down here......

    //-------------CODE--------------------------------
    now = new Date();
    dateNow = now.getDate();
    monthNow = now.getMonth();
    daysInMarch = 31;
    daysInApril = 30;
    daysInMay = 15;
    if (monthNow == 1) {
    daysLeftInMarch = daysInMarch-dateNow;
    daysLeft = daysLeftInMarch+daysInApril+31;
    } else if (monthNow == 2) {
    daysLeftInApril = daysInApril-dateNow;
    daysLeft = daysLeftInApril+31;
    } else if (monthNow == 3) {
    daysLeftInMay = daysInMay-dateNow;
    daysLeft = daysLeftInMay+31;
    } else {
    daysLeft = 31-dateNow;
    }
    DateCount = daysLeft;
    //----------------CODE-------------------------

    Thanx in advance

  2. #2
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    I'm a bit busy at work, so why not look at
    :

    http://board.flashkit.com/board/show...hreadid=257914

    swills

  3. #3
    Senior Member
    Join Date
    Sep 2000
    Posts
    467
    when you use .getMonth(); you will receive a number.
    0 = january
    1 = february
    2 = march
    3 = april

    you have put the wrong numbers in you if-statements.
    this code should do the trick
    Code:
    now = new Date(); 
    dateNow = now.getDate(); 
    monthNow = now.getMonth(); 
    daysInMarch = 31; 
    daysInApril = 30; 
    daysInMay = 15; 
    if (monthNow == 2) { 
    daysLeftInMarch = daysInMarch-dateNow; 
    daysLeft = daysLeftInMarch+daysInApril+31; 
    } else if (monthNow == 3) { 
    daysLeftInApril = daysInApril-dateNow; 
    daysLeft = daysLeftInApril+31; 
    } else if (monthNow == 4) { 
    daysLeftInMay = daysInMay-dateNow; 
    daysLeft = daysLeftInMay+31; 
    } else { 
    daysLeft = 31-dateNow; 
    } 
    DateCount = daysLeft;

  4. #4
    Senior Member
    Join Date
    Feb 2001
    Posts
    114
    Originally posted by ^1letser
    when you use .getMonth(); you will receive a number.
    0 = january
    1 = february
    2 = march
    3 = april

    you have put the wrong numbers in you if-statements.
    this code should do the trick
    Code:
    now = new Date(); 
    dateNow = now.getDate(); 
    monthNow = now.getMonth(); 
    daysInMarch = 31; 
    daysInApril = 30; 
    daysInMay = 15; 
    if (monthNow == 2) { 
    daysLeftInMarch = daysInMarch-dateNow; 
    daysLeft = daysLeftInMarch+daysInApril+31; 
    } else if (monthNow == 3) { 
    daysLeftInApril = daysInApril-dateNow; 
    daysLeft = daysLeftInApril+31; 
    } else if (monthNow == 4) { 
    daysLeftInMay = daysInMay-dateNow; 
    daysLeft = daysLeftInMay+31; 
    } else { 
    daysLeft = 31-dateNow; 
    } 
    DateCount = daysLeft;
    Thanx ... Those where the enlighting words i was looking for... i did know flash isn't able to count from a zeropoint but i forgot from pure frustration...

    Thanx again..

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