Animation

  1. Home
  2. Computing & Technology
  3. Animation

ActionScripting Basics: Basic Date Functions

By Adrien-Luc Sanders, About.com

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

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Animation

  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.