12 Replies Latest reply on Jul 20, 2006 1:32 AM by Newsgroup_User

    Switch On/Off does not work

    Level 7
      Hello:
      This is for a trivial game type.
      I have a sprite that make a litle animation when a button is MouseUp. While
      animation take place I don't want that nobdy click on answer (textbox). I
      have put the following:

      --this is button that launch animation
      global AnimationSwitch
      On MouseUp me
      AnimationSwitch=True
      MakeAnimation
      AnimationSwitch=False
      end

      --this is a textbox MouseUp
      global AnimationSwitch
      On MouseUp me
      If AnimationSwitch =true then exit
      RespondAnswer
      end

      Does not work this code. How can control when the animation is finished
      then enabled to click on answer textbox?
      (If I click some times while animation is running, when is finished, quickly
      an answer is presenting.)
      Thank you very much





        • 1. Re: Switch On/Off does not work
          Level 7
          Yes, Director will read these three lines:

          AnimationSwitch=True
          MakeAnimation
          AnimationSwitch=False

          do each thing as fast as it can. It looks like you are calling another
          function, MakeAnimation, in the middle there.

          You could, possibly, put the AnimationSwitch = False at the end of that
          function. Or, you could return a value the calling function to change
          the value.

          --
          Rob
          _______
          Rob Dillon
          Adobe Community Expert
          http://www.ddg-designs.com
          412-243-9119

          http://www.macromedia.com/software/trial/
          • 2. Re: Switch On/Off does not work
            Level 7
            Thank you.
            I have done what you have told me and does not work.
            Can you give any other idea?


            "Rob Dillon - Adobe Community Expert" <rob@-remove-ddg-designs.com> escribi�
            en el mensaje news:rob-98BFB0.15422819072006@forums.macromedia.com...
            > Yes, Director will read these three lines:
            >
            > AnimationSwitch=True
            > MakeAnimation
            > AnimationSwitch=False
            >
            > do each thing as fast as it can. It looks like you are calling another
            > function, MakeAnimation, in the middle there.
            >
            > You could, possibly, put the AnimationSwitch = False at the end of that
            > function. Or, you could return a value the calling function to change
            > the value.
            >
            > --
            > Rob
            > _______
            > Rob Dillon
            > Adobe Community Expert
            > http://www.ddg-designs.com
            > 412-243-9119
            >
            > http://www.macromedia.com/software/trial/


            • 3. Re: Switch On/Off does not work
              Level 7
              The success of this method depends on the rest of the code that you are
              using. If give us an example, someone may be able to solve the problem.

              --
              Rob
              _______
              Rob Dillon
              Adobe Community Expert
              http://www.ddg-designs.com
              412-243-9119

              http://www.macromedia.com/software/trial/
              • 4. Re: Switch On/Off does not work
                Level 7
                > I have done what you have told me and does not work.
                > Can you give any other idea?

                I suspect you need to detect when your animation has finished and notify
                interested parties when this happens (so that they can re-enable
                themselves, ...)
                How you do this depends perhaps on your existing design and how you've
                implemented your animation
                • 5. Re: Switch On/Off does not work
                  Level 7
                  Thank you:
                  The "MakeAnimation" handler, call to three more handlers, the last one
                  Return True to activate the textbox answer.
                  The animation only take the coordenates of sprite and move it in the stage.
                  Is too much code to post it.
                  Is there any way to disable the mouse click and enable when the anmation
                  finish?
                  Best regards


                  "Sean Wilson" <webforumsuser@macromedia.com> escribi� en el mensaje
                  news:e9m9qm$1gk$1@forums.macromedia.com...
                  >> I have done what you have told me and does not work.
                  >> Can you give any other idea?
                  >
                  > I suspect you need to detect when your animation has finished and notify
                  > interested parties when this happens (so that they can re-enable
                  > themselves, ...)
                  > How you do this depends perhaps on your existing design and how you've
                  > implemented your animation


                  • 6. Re: Switch On/Off does not work
                    Level 7
                    > Is there any way to disable the mouse click and enable when the anmation
                    > finish?

                    Yes, but again - it depends on your design and implementation. If you're
                    running the animation in a tight repeat loop then no other activity can
                    interrupt it, but if it's score-based or lingo-driven then you'll need
                    to notify sprites to turn off when it starts and on again when it stops.
                    Determining when your animation is complete is the key here, and I can't
                    see your file so it's difficult to recommend how to approach a solution.
                    You are not providing enough info.
                    • 7. Re: Switch On/Off does not work
                      Level 7
                      The animation is very simple. Some help in this beautiful forum told me.
                      This happens depend on roll dice 1-6 times. When this animation is done,
                      ask for question.

                      on jump (whichSprite)
                      currVert=sprite(whichSprite).locV
                      currHorz=sprite(whichSprite).loch
                      CurrMember=sprite(whichSprite).member
                      jumpDistance=45
                      jumpHeight=20
                      --going up
                      sprite(whichSprite).member=member("jump2")
                      sprite(whichSprite).locV=currVert-jumpHeight/2
                      sprite(whichSprite).loch=currHorz+jumpDistance/4
                      updatestage
                      delayMe
                      --at the top
                      sprite(whichSprite).member=member("jump3")
                      sprite(whichSprite).locV=currVert-jumpHeight
                      sprite(whichSprite).loch=currHorz+jumpDistance/2
                      updatestage
                      delayMe
                      --going down
                      sprite(whichSprite).member=member("jump2")
                      sprite(whichSprite).locV=currVert+jumpHeight/2
                      sprite(whichSprite).loch=currHorz+(jumpDistance/4)*3
                      updatestage
                      delayMe
                      ---finish jump and return to standing position
                      sprite(whichSprite).member=CurrMember
                      sprite(whichSprite).locV=currVert
                      sprite(whichSprite).loch=currHorz+jumpDistance
                      updatestage
                      end





                      "Sean Wilson" <webforumsuser@macromedia.com> escribi� en el mensaje
                      news:e9meml$76s$1@forums.macromedia.com...
                      >> Is there any way to disable the mouse click and enable when the anmation
                      >> finish?
                      >
                      > Yes, but again - it depends on your design and implementation. If you're
                      > running the animation in a tight repeat loop then no other activity can
                      > interrupt it, but if it's score-based or lingo-driven then you'll need to
                      > notify sprites to turn off when it starts and on again when it stops.
                      > Determining when your animation is complete is the key here, and I can't
                      > see your file so it's difficult to recommend how to approach a solution.
                      > You are not providing enough info.


                      • 8. Re: Switch On/Off does not work
                        Level 7
                        > on jump (whichSprite)

                        So somewhere you're repeatedly calling #jump, or it only happens once?
                        If you only call it once I don't see what your problem is.
                        Presumably your delayMe handler kills some time before returning?
                        • 9. Re: Switch On/Off does not work
                          Level 7
                          The Jump works depend on random(6), so can repeated from 1 to 6 times.
                          --TimesJump=random(6)
                          The DelayMe is necessary to see the animation smooth.
                          Than you.

                          "Sean Wilson" <webforumsuser@macromedia.com> escribi� en el mensaje
                          news:e9mjap$btq$1@forums.macromedia.com...
                          >> on jump (whichSprite)
                          >
                          > So somewhere you're repeatedly calling #jump, or it only happens once? If
                          > you only call it once I don't see what your problem is.
                          > Presumably your delayMe handler kills some time before returning?


                          • 10. Re: Switch On/Off does not work
                            Level 7
                            > The Jump works depend on random(6), so can repeated from 1 to 6 times.
                            > --TimesJump=random(6)
                            > The DelayMe is necessary to see the animation smooth.

                            It looks to me like you are completely locking out other interaction.
                            You might try calling flushInputEvents() at the end of the handler that
                            repeatedly calls #jump.
                            • 11. Re: Switch On/Off does not work
                              Level 7
                              Thank you. I'll try it and tell you.
                              Best regards.

                              "Sean Wilson" <webforumsuser@macromedia.com> escribi� en el mensaje
                              news:e9nd8p$a0n$1@forums.macromedia.com...
                              >> The Jump works depend on random(6), so can repeated from 1 to 6 times.
                              >> --TimesJump=random(6)
                              >> The DelayMe is necessary to see the animation smooth.
                              >
                              > It looks to me like you are completely locking out other interaction. You
                              > might try calling flushInputEvents() at the end of the handler that
                              > repeatedly calls #jump.an


                              • 12. Re: Switch On/Off does not work
                                Level 7
                                As a frame script:-

                                -------------------------------------------------------------
                                property jumpDistance, jumpHeight
                                property sprt, currHorz, currVert, currMember
                                property active, phase, waiting

                                on jump me, whichSprite
                                sprt=sprite(whichSprite)
                                phase=0
                                active=true
                                waiting=0
                                currMember=sprt.member
                                currHorz=sprt.locH
                                currVert=sprt.locV
                                end jump

                                on activeState
                                return active
                                end activeState

                                on enterFrame
                                if not(active) then exit
                                if the milliseconds-waiting<0 then exit
                                case phase of
                                0:
                                --going up
                                sprt.member=member("jump2")
                                sprt.locV=currVert-jumpHeight/2
                                sprt.loch=currHorz+jumpDistance/4
                                phase=phase+1
                                waiting=the milliseconds+100 -- delay till next action
                                1:
                                --at the top
                                sprt.member=member("jump3")
                                sprt.locV=currVert-jumpHeight
                                sprt.loch=currHorz+jumpDistance/2
                                phase=phase+1
                                waiting=the milliseconds+100 -- delay till next action
                                2:
                                --going down
                                sprt.member=member("jump2")
                                sprt.locV=currVert+jumpHeight/2
                                sprt.loch=currHorz+(jumpDistance/4)*3
                                phase=phase+1
                                waiting=the milliseconds+100 -- delay till next action
                                3:
                                ---finish jump and return to standing position
                                sprt.member=CurrMember
                                sprt.locV=currVert
                                sprt.loch=currHorz+jumpDistance
                                active=false
                                end case
                                end enterFrame

                                on exitFrame
                                go the frame
                                end exitFrame

                                on beginSprite
                                active=false
                                jumpDistance=45
                                jumpHeight=20
                                phase=0
                                end beginSprite

                                -------------------------------------------------------------

                                To make it happen to, e.g., sprite 12, use
                                sendSprite(-5, #jump, 12)

                                Basically, you should never use updateStage or use loops to delay things.
                                Instead, use the repeating frame events.

                                The frame script is channel -5.

                                To test if it is active in the context of your original post, use
                                if sendsprite(-5, #activeState) then exit

                                Andrew