4 Replies Latest reply on Apr 24, 2011 7:32 PM by Jiguoliang

    how to create show or hide

    Jiguoliang

      hi, all

      when mouse cursor rollover a button, show the button's message, when mouse leave,hide the message, how to create this effect, thanks

        • 1. Re: how to create show or hide
          jchunick

          -- create a behavior script

           

          on mouseEnter me

          -- code here to show a button's message

          end

           

          on mouseLeave me

          -- code here to hide a button's message

          end

           

          -- end of behavior script

           

           

          After creating the behavior script attach it to your button sprite. I am not clear what type of message you want to display, but it sounds like a tooltip. If you are looking for a tooltip script then you can find one here: http://www.director-online.com/buildArticle.php?id=1139

          • 2. Re: how to create show or hide
            Jiguoliang Level 1

            sorry,  I don't descibe clearly what I want. acturally, when mouse over the button, show a message panel member created by Ilustrator, for example, there are several countries name as buttons, like USA, France and Russia, when mouse over the USA,  show the cast member of population infomation of the USA,  mouse leave, then hide the member, mouse over the France, show the population infomation of the France....

             

            I know the on mouseEnter me or  on mouseLeave me, but I don't know how to write the code to show or hide the message member!

            • 3. Re: how to create show or hide
              Dean Utian Adobe Community Professional

              Here's one way. Say you have sprite 1 as your 'rollover' member, sprite 2 as the graphic you want to display. By default, you could have sprite 2 off stage, maybe 1000 pxels to the right of where it should appear. Then you could shift the horizontal location (locH) of the sprite by the following behavior:

               

              on mouseEnter me

              sprite(me.spriteNum+1).locH = sprite(me.spriteNum+1).locH - 1000

              end

               

              on mouseLeave me

              sprite(me.spriteNum+1).locH = sprite(me.spriteNum+1).locH + 1000

              end

               

              So, when you move the mouse over sprite 1, which represents (me.spriteNum), then the horizontal location of sprite 2 (me.spriteNum+1) shifts 1000 to the left. When you leave the sprite, it shifts 1000 pixels to teh right so goes off stage. The 1000 would depend on how wide your stage is.

               

              Dean

              • 4. Re: how to create show or hide
                Jiguoliang Level 1

                thanks,Utian, I think I understand your method!