1 Reply Latest reply on Aug 13, 2008 7:49 AM by robdillon

    Making a script waiting for a button click

    ElNix
      Hi,

      I'm making a one-bloc script and I need the script to pause and wait for a button click.

      I tried this :

      repeat while(click=0)
      nothing
      end repeat

      with the variable "click" set to 0 at the beggining and a script in each button updating it (for esample the button 1 has the script :

      on mouseUp
      global click
      click=1
      end

      and so on for the other buttons.

      But I only get a total freeze of the movie.


      Do you have a solution ?

      Thank you for your help


        • 1. Re: Making a script waiting for a button click
          robdillon Most Valuable Participant
          You don't need the repeat loop. That's what is trying up your movie. Are you attempting to do this in a movie script window or as a behavior?

          The simplest solution is to write one behavior and attach it to each button instance on the stage. You could do something as simple as this:

          property thisSprite
          property callout

          on beginSprite me
          thisSprite = me.spriteNum
          end

          on getPropertyDescriptionList me
          myPropList = [:]
          myPropList.addProp(#callout,[#comment:"select the number for this button:",#format:#integer,#range:[#min:1,#max:10],#default:1)])
          return myPropList
          end

          on mouseUp me
          put callout
          end

          Or, you could just put the current sprite number: "put thisSprite".

          In any case, the behavior will do the waiting for you.