1. Home
  2. Computing & Technology
  3. Animation

ActionScripting Basics: Basic Date Functions

By , About.com Guide

8 of 8

Lump it all together inside an encompassing pair of parentheses, and you’ve got a solid string.

So why that pesky little “+1” in (today.getMonth() + 1)? Weeeeell, that’s just an oddity of Flash’s. It returns a 0 for January, 1 for February, 2 for March, etc.--like many scripting languages, it starts labeling/counting at 0, instead of at one. If you leave it as-is, then you’ll actually display the date for the current day, but last month. Adding the +1 will cause the value returned to reflect the current month.

Now for the last line:

_root.textdisplay.text="Today's date: "+dateTextField;

This is a variation of what we covered in the lesson on passing fetched values to a named dynamic text box, and will pass the string put together for variable dateTextField to the text box that we created at the start of the lesson, along with whatever text we specify.

My little date display movie is here.

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.