4 Replies Latest reply on Jul 28, 2006 3:14 AM by Goo101

    timelines

    Goo101 Level 1
      I have a problem in an application I am developing. I am trying to do an automated version of the application in order to show it's basic functionality as part of a marketing exercise.
      On my second screen the user enters a voucher number in order to be able to proceed with their purchase. In order to automate this I have stretched the timeline out over a number of key frames, each with their own AS code designed to add a new number to the overall voucher number. Each key frame is 16 frames aparts playing the timeline at a rate of 16fps. So every second a new number gets added to the overall voucher number. Each of these keyframes has the same code adding a different number each time, as per the following code . . .

      onEnterFrame()

      stop();
      Selection.setFocus(itxtVoucherNo);
      this.itxtVoucherNo.text = "20060726111503";
      trace("entered the number 3 in itxtVoucherNo.");
      play();

      At the end of this series of keyframes on the timeline, there are a couple of other keyframes . . .

      One of which makes it look like the 'Ok' button has been pressed, as per the following code . . .

      import flash.filters.GlowFilter;

      onEnterFrame()

      var gfOk:GlowFilter = new GlowFilter(0x000000, .5, 40, 20);
      btnOk.filters = [gfOk];
      play();

      And the other which takes the app. to the next screen in logical sequence . . .

      onEnterFrame()

      // GoTo Screen behavior
      if((this._parent.Format != undefined) && (this._parent.Format != null))
      {
      var screen = null;
      var target = this;
      while((screen == null) && (target != undefined) && (target != null))
      {
      if(target instanceof mx.screens.Screen)
      {
      screen = target;
      }
      else
      {
      target = target._parent;
      }
      }
      if(screen instanceof mx.screens.Slide)
      {
      screen.gotoSlide(this._parent.Format);
      }
      }
      // End GoTo Screen behavior

      stop();

      The problem is when testing the app. using the compiled .swf file everything works fine, until my app. gets to this next logical screen where it "throws a wobbley" (for want of a better term) and returns to the second screen again to go through the process of adding the numbers to the voucher number field again.
      Why is the timeline on my second screen looping like this even though the app. is on a different screen? How do I get it to stop doing this!?
      Any help would as always be greatly appreciated. I don't understand the logic here (especially seeing as I have used the stop(); command all over this app.) and it's driving me mad as per usual.
      Thanks . . . Kevin.
        • 1. Re: timelines
          chrism59 Level 1
          you might want to look into calling a timer function and stopping the timer on the next screen.

          function procAddToVoucher() {
          place your onEnter code here
          }
          processVoucher = setInterval(procAddToVoucher, 3000);

          when you get to the next location place this code in the first frame

          clearInterval(processVoucher )

          you can look at the code using help. This is a clean way of repeating a process with making the movie lopp therough frames. The number you enter will effect the length of time between calls to the function.
          • 2. Re: timelines
            Goo101 Level 1
            Thanks chrism59, but using the setInterval method would negate the need to use the timeline in the first place. I'm happy enough using the timeline, I just want to figure out how to stop it looping!?

            Anyone else have any ideas?
            • 3. Re: timelines
              Goo101 Level 1
              Ah, I see what you mean chrism59, I should only add this code to the last keyframe on the timeline. What I don't understand though is why the timeline from the 2nd screen is still looping when the app. is already on the 3rd screen? Why is this happening?
              • 4. Re: timelines
                Goo101 Level 1
                I managed to get this sorted myself and stop the timeline in the second screen looping via the intensive use of trace statements and ultimately a strategically placed stop(); command.

                Ah, the joys of coding, eh!?