1 Reply Latest reply on Jan 19, 2007 3:31 AM by Newsgroup_User

    How to enable/Disable and a Button

    Atul_Saxena Level 1
      Hi everyone
      I have two buttons on stage. What i want is at one time only one button should be enabled and other disabled....
      Please suggest a way to achieve this

      Thanks in advance
      Atul Saxena
        • 1. Re: How to enable/Disable and a Button
          Level 7
          That depends on how you want to initiate the able/disable feature.

          I'll assume that clicking on one button will disable it and enable the
          other. When one button is clicked it sends a message to both. When each
          receives the message it will either enable or disable based on whether it
          was the actively clicked button or the idle button respectively. By sending
          that same message in the beginSprite handler, one button will be disabled
          and the other enabled when the sprites are first encountered in the score.
          You can change which is initialized as enabled or disabled by switching
          their channel order. Just copy this code into an empty behavior script and
          assign it to both buttons you've created.

          property pS, spriteNum, pStatus

          on beginSprite me
          pS = sprite (spriteNum)
          pStatus = #enabled
          SendAllSprites (#ChangeStatus, spriteNum)
          end

          on mouseUp me
          if pStatus = #enabled then
          SendAllSprites (#ChangeStatus, spriteNum)
          end if
          end

          on ChangeStatus me, sprNum
          if sprNum = spriteNum then
          pStatus = #disabled
          pS.blend = 40
          else
          pStatus = #enabled
          pS.blend = 100
          end if
          end


          --
          Craig Wollman
          Lingo Specialist
          Word of Mouth Productions
          212-928-9581

          www.wordofmouthpros.com
          "Atul Saxena" <webforumsuser@macromedia.com> wrote in message
          news:eoq4vc$j6b$1@forums.macromedia.com...
          > Hi everyone
          > I have two buttons on stage. What i want is at one time only one button
          > should be enabled and other disabled....
          > Please suggest a way to achieve this
          >
          > Thanks in advance
          > Atul Saxena