1. Home
  2. Computing & Technology
  3. Animation

ActionScripting Basics: Basic Date Functions

By , About.com Guide

7 of 8

With those functions defined, it’s easier to break the rest down.

dateTextField = ((today.getMonth() + 1) + "/" + today.getDate() + "/" + today.getFullYear()) ;

today is placed before the functions and separated by a period to tell each function that it’s referencing our new date object.

The + operand is used to string everything together. When you use + with functions like these, it appends each new value after the + sign to the string concatenated for the overall output of variable dateTextField. (You can also use it as an arithmetical operator in mathematical functions/scripts.)

If you left it just as the functions strung together, you’d end up with something like 08202006, with no breaks at all. That’s where the “/” comes in. Whenever something is placed inside quotes, Flash appends it as-is, instead of trying to read it as a variable or operand.

To break this down in descriptive terms, what this string tells Flash is, “Fetch the current month, separate it with a backslash, fetch the current day, separate that with a backslash, and then fetch the current year, and parcel all that together as a single string named “dateTextField”.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. ActionScripting Basics: Basic Date Functions

©2009 About.com, a part of The New York Times Company.

All rights reserved.