Modify your script
You'll modify your script to compensate for the zero indexing.
Add +1 to the value when you create
1.
expected month number appears. That line of script should read as follows:
var currentMonth:Number = myDate.getMonth()+1;
Comment the trace statement:
2.
//trace (currentMonth);
Below the trace statement, set the
3.
currentDate_txt.autoSize = true;
Use the text property of your text box to display today's date in the form Today is mm/dd/yyyy.
4.
Use the
currentMonth
getFullYear()
currentDate_txt.text="Today is "+currentMonth+"/"+ myDate.getDate() + "/
"+myDate.getFullYear();
Verify that your script appears as follows:
5.
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();
Save and test the document. The current date should appear in the SWF file window.
6.
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
Creating a custom class
While ActionScript includes many classes of objects, such as the MovieClip class and the Color
class, there will be times when you need to construct your own classes so you can create objects
based on a particular set of properties or methods.
To create a class that defines each of the new objects, you create a constructor for a custom object
class and then create new object instances based on that new class, as in the following example:
Note: The following ActionScript is an example only. You should not enter the script in your lesson
FLA file.
function Product (id:Number, prodName:Name, price:Number)
{
this.id:Number = id;
this.prodName:String = prodName;
this.price:Number = price;
}
currentMonth,
autoSize
variable you have already created, plus the
methods of the Date object:
"Set up your workspace" on page
and test your document to be sure the
property of your text box to
getDate()
Creating a custom class
:
true
and
113.
115
Need help?
Do you have a question about the FLASH MX 2004-LEARNING FLASH and is the answer not in the manual?
Questions and answers