Modify your script

You'll modify your script to compensate for the zero indexing.

  1. Add +1 to the value when you create currentMonth, and test your document to be sure the expected month number appears. That line of script should read as follows:
    var currentMonth:Number = myDate.getMonth()+1;
    
  2. Comment the trace statement:
    //trace (currentMonth);
    
  3. Below the trace statement, set the autoSize property of your text box to true:
    currentDate_txt.autoSize = true;
    
  4. Use the text property of your text box to display today's date in the form Today is mm/dd/yyyy. Use the currentMonth variable you have already created, plus the getDate() and getFullYear() methods of the Date object:
    currentDate_txt.text="Today is "+currentMonth+"/"+ myDate.getDate() + "/"+myDate.getFullYear();
    
  5. Verify that your script appears as follows:
    var myDate:Date=new Date();
    var currentMonth:Number = myDate.getMonth()+1;
    //trace (currentMonth);
    currentDate_txt.autoSize = true;
    currentDate_txt.text="Today is "+currentMonth+"/"+ myDate.getDate() + "/"+myDate.getFullYear();
    
  6. Save and test the document. The current date should appear in the SWF file window.

Note: An example finished file of the document you just created, named handson1.fla, is located in your finished files folder. For the path, see Set up your workspace.