2 Replies Latest reply on Apr 27, 2006 4:18 AM by Newsgroup_User

    delaying the execution of an if statement

    complexity Level 1
      Ive set up an if statement which I want to act as a trigger. Its sitting on frame 20 (only) of a 40 frame animation.

      I thought that the if statement would only execute when that frame is only played, but it seems to execute as soon as frame 1 plays. How do I stop it from executing like that.?
        • 1. Re: delaying the execution of an if statement
          gameMaker
          you could try enclosing your if statement with

          if (_currentframe==20)
          {

          //your code here
          }
          • 2. Re: delaying the execution of an if statement
            Level 7
            >> Ive set up an if statement which I want to act
            >> as a trigger. Its sitting on frame 20 (only) of a
            >> 40 frame animation.

            Okay.

            >> I thought that the if statement would only execute
            >> when that frame is only played,

            That's right.

            >> ... but it seems to execute as soon as frame 1 plays.
            >> How do I stop it from executing like that?

            You shouldn't have to. There must be something else going on that you
            haven't described.

            > you could try enclosing your if statement with
            >
            > if (_currentframe==20) {
            > //your code here
            > }

            Yes, that would ensure that code only executes on frame 20, but it would
            be meaningless to put something like that on, say, frame 15. ActionScript
            script executes on a frame-by-frame basis, so if code is on frame 20, it
            will only execute when frame 20 of *that timeline* is encountered, with or
            without the if() statement.


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