A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need Help With Code!!

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    6

    Need Help With Code!!

    Could anyone help me with this Countdown code, I have followed a tutorial exactly and it still comes out wrong.

    Basicaly I have created a dynamic textbox on an unlabled layer I have embded the fonts and labled the text box "time_txt" then added a new layer and labled it "actions" then on the first slot I've added the code as follows:

    this.onEnterFrame = function() {

    var todayate = new Date();
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();

    var targetDateate = new Date(currentYear,9,24);
    var targetTime = targetDate.getTime();

    var timeLeft = targetTime - currentTime;

    var sec = Math.floor(timeLeft/1000);
    var min = Math.floor(sec/60);
    var hrs = Math.floor(min/60);
    var days = Math.floor(hrs/24);
    sec = string(sec % 60);
    if (sec.length < 2) {
    sec = "0" + sec;
    }
    min = string(min % 60);
    if (min.length < 2) {
    min = "0" + min;
    }
    hrs = string(hrs % 24);
    if (hrs.length < 2) {
    hrs = "0" + hrs;
    }
    days = string(days);

    var counter:String = days + ":" + hrs + ":" + min + ":" + sec;
    time_txt.text = counter;
    }

    I want it to count down to 24/09/2007 (the date season 2 of Heroes is out)

    Hope someone can help.

    Max

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    have tested and your code is fine
    the only reason for failure can be no instance name on textfield

    fwiw to prevent seeing Smilies in your code when posting,
    enclose the text with - [ CODE ][ /CODE ] (# icon in advanced post mode) -

    Code:
    var today:Date = new Date();
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();
    
    var targetDate:Date = new Date(currentYear,9,24);
    var targetTime = targetDate.getTime();

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