3 Replies Latest reply on Apr 24, 2006 11:23 AM by Newsgroup_User

    Automatically retrieve date

    majonsey
      The user must fill in the date in a specified text field, but it would be nicer if I could have it retrieve the current date that the flash page is accessed and put it in the text field automatically. Is there a way to do this? Is there a certain command that retrieves the current date? I've tried getDate and nothing happened.
        • 1. Re: Automatically retrieve date
          shyaway Level 1
          Flash help provided:

          var today_date ate = new Date();
          var date_str:String = ((today_date.getMonth()+1)+"/"+today_date.getDate()+"/"+today_date.getFullYear());
          trace(date_str); // displays current date in United States date format

          • 2. Re: Automatically retrieve date
            majonsey
            I don't know a whole lot about flash. Now my question would be: where does that actionscript go? I can't put it on the text field itself and when i put it on the frame itself, nothing happens when i run it.
            • 3. Re: Automatically retrieve date
              Level 7
              majonsey,

              > I don't know a whole lot about flash. Now my question
              > would be: where does that actionscript go?

              Heh, that's pretty important, isn't it? These basic questions are
              likely going to be a stumbling block until you get to know the ropes. Even
              if you knew where to put the code, it sounds like you're unfamiliar with the
              concept of objects in the first place -- with the idea that the Date class
              defines a particular kind of object that provides information about a given
              date.

              > I can't put it on the text field itself and when i put it on
              > the frame itself, nothing happens when i run it.

              Something should definitely happen. You should see date information in
              the Output panel, because of the trace() statement in there.

              Here's what I suggest. It's not the quickest, easiest approach, but I'm
              confident it's the approach that will give you the highest comfortable level
              with programming in Flash. And then you'll be able to use not only the Date
              class, but any other class in ActionScript, to meet your needs.

              Read this article here ...

              http://www.quip.net/blog/2006/flash/actionscript-20/ojects-building-blocks

              ... and then read these articles here ...

              http://www.macromedia.com/devnet/flash/articles/flash8_bestpractices.html
              http://livedocs.macromedia.com/flash/8/main/Part3_Learning_AS.html
              http://www.macromedia.com/devnet/flash/articles/as_bestpractices.html

              Now, that's a lot of reading! But don't shy away from it. Using Flash,
              especially for programming, you really need to read the "Owner's Manual,"
              and those articles will get you started. When you're grounded in the basics
              like where to put code, how ActionScript is organized, and so on, you'll
              have very good footing. You'll be able to think to yourself, "Okay, I need
              something to do with dates ... is there a Date class? Ah, there is!" And
              then check its properties (characteristics), methods (things it can do), and
              events (things it can react to).

              Programming isn't easy. But get yourself acquainted with the
              playing field first, and the rest follows.


              David
              stiller (at) quip (dot) net
              Dev essays: http://www.quip.net/blog/
              "Luck is the residue of good design."