4 Replies Latest reply on Mar 14, 2007 11:04 AM by Voddie

    AS scriptinghelp required

    Voddie Level 1
      Hi

      Im using Flash 8.

      I have followed a tutorial on creating a digital clock and ctraed a movie that brings the time and full date.

      What I am trying to do next is create the digital clock using images instead of dynamic text. I have the images I require but I am not sure which way to approach it.

      The fla can be downloaded here: http://www.voddie.com/testbed/digitalclock/digital_clock.fla

      The coding i have used is below

      Thanks for any assistance offered

        • 1. Re: AS scriptinghelp required
          MotionMaker Level 1
          Many approaches.

          You can put the digit images 0-9 in a single MovieClip on individual frames. For example frame 1 might have the image for 0 and frame 2 for 1 and so on.

          Add a stop() action to the first frame.

          Then add the MovieClip for each of the digits in the clock such as hourDigit1_mc, hourDigit2_mc, minuteDigit1_mc, minuteDigit2_mc and so forth.

          Then modify your code to determine the digit values and use gotoAndStop() to select the frame in the clips. Ex: hourDigit1_mc.gotoAndStop(2) for showing the 1 image.

          Again just one approach.

          • 2. Re: AS scriptinghelp required
            Voddie Level 1
            Hi

            Thanks for responding

            That is a little beyond my as skills. Could you explain further please?

            Especially the "Then modify your code to determine the digit values and use gotoAndStop() to select the frame in the clips. Ex: hourDigit1_mc.gotoAndStop(2) for showing the 1 image." part.

            Thanks in advance
            • 3. Re: AS scriptinghelp required
              MotionMaker Level 1
              "That is a little beyond my as skills. "
              You would need to understand basic scripting including arrays . It also assumes you understand the code you originally posted. That includes the Date Class.

              "Especially the 'Then modify your code to determine the digit values and use gotoAndStop() to select the frame in the clips. Ex: hourDigit1_mc.gotoAndStop(2) for showing the 1 image' part."
              Example
              Assume a movieClip has the 0 image on frame 1, the 1 image on frame 2 and so on. It also has a stop() action on frame 1.

              Assume you have two instances minuteDigit1_mc and minuteDigit2_mc.

              The code posted needs to determine the first and second digit in the String minutes. You can use String.substr() for that.
              See attached code below.

              You would need to repeat for the hours and seconds to complete for the time. For the hour you need to perform the same left padding of the 0 as is done for minutes and seconds. You may also need this for the month and day variables.

              You probably no longer need the arrays for the days of the week and month names and those variables for them. However you may want to leave them for some other display intended.


              Another item I noticed in the code is the use of Length. This is a deprecated Flash function and should be replaced with String.length property.

              • 4. Re: AS scriptinghelp required
                Voddie Level 1
                Hi

                Thanks for explaining more.

                Firstly, Im not sure how I replace Length. with String.length property. Will get reading....

                Ive tried to follow the coding you suggested but to no avail.

                Latest fla http://www.voddie.com/testbed/digitalclock/myDigital.fla

                Please let me know where Im going wrong.

                THanks in advance