8 Replies Latest reply on Jan 29, 2007 10:46 AM by eoinie

    visible of sprite script trouble

    eoinie
      hi list
      I need to have a few sprites invisible on opening of my program and have them appear when rolled over. I am using the following script in the script channel above the play head:

      on mouseLeave me
      the visible of sprite 34 = 0

      end mouseLeave me

      Trouble is that when the program starts some or all of them are visible. It works perfectly when I roll-over them subsequently i.e. they all appear and disappear properly. All the sprites are visible all the time when I create the projector.
      I have re-booted several times to no avail. Any ideas?

      Eoin
        • 1. Re: visible of sprite script trouble
          Level 7
          One of the effects of the visible of sprite property is that this
          property will make the sprite active or not. If a sprite is not visible,
          it is also not active and won't react to user events like a rollover.

          To have a sprite be not visible and still react to user events use the
          blend property of the sprite.

          Be aware that the visible of sprite property belongs to the sprite
          channel and not to the sprite that may currently occupy that channel. If
          you turn off the visible property of a sprite channel, it remains off
          throughout the rest of the score unless it is turned on again.

          The blend property belongs to the sprite in the channel, so setting a
          particular sprite's blend to 0 will not effect any other subsequent
          sprite occupying the same channel later in the score.

          If you want the sprites to be not visible initially, then set the blend
          property to 0 in the beginSprite function of a behavior attached to each
          sprite. Then you can change the blend property's value to 100 when you
          want the sprite to be visible. For instance:

          ----------
          property thisSprite

          on beginSprite me
          thisSprite = me.spriteNum
          sprite(thisSprite).blend = 0
          end

          on mouseEnter me
          sprite(thisSprite).blend = 100
          end

          on mouseLeave me
          sprite(thisSprite).blend = 0
          end
          -----------

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

          http://www.macromedia.com/software/trial/
          • 2. visible of sprite script trouble
            ICMA Centre
            use a movie script - startmovie or preparemovie - to set the visbility of the sprite channels to 0:

            --assuming you are using sprites 30 - 35 as the invisible sprites.
            --if your sprites are in non-sequential channels, just set the visible
            --for each channel separately, and remove the repeat lingo.

            on startMovie
            repeat with thisSpriteChan = 30 to 35
            set the visible of sprite thisSpriteChan = 0
            end repeat
            end startMovie

            also insert a frame at the start of the movie (if you haven't already) with these channels empty - this will ensure that there is nothing in those channels before it switches the visibility off.
            • 3. Re: visible of sprite script trouble
              eoinie Level 1
              Hi folks
              Thanks for the replies. Unfortunately neither seems to work for me??

              Eoin
              • 4. Re: visible of sprite script trouble
                Level 7
                Can you explain in more detail what you are trying to accomplish. Please
                be specific.

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

                http://www.macromedia.com/software/trial/
                • 5. Re: visible of sprite script trouble
                  eoinie Level 1
                  I have a menu at the start of the program with links to various areas. When I roll-over these links I want a dot to appear next to the link and when I roll-off i want the dot to disappear. This is happening within the program but when I start all dots are showing until such time as I roll-over and roll-off at which stage the dots do disappear. This used to work fine for me in other work.

                  Hope this is clear enough and thanks

                  Eoin
                  • 6. Re: visible of sprite script trouble
                    Level 7
                    Are you saying that the dots correctly become visible when you enter the
                    sprite, then they disappear when they should, but then they do not
                    re-appear later?

                    If that is the case, then the answer (as Rob has pointed out) is that if
                    a sprite's .visible property is 1 (or TRUE), then it will not receive
                    any mouse events, so an invisible sprite never sees your on mouseEnter
                    script (which I assume is what you mean by roll-over). Instead of using
                    the visible property, set the blend to 0 for invisible and 100 for fully
                    visible. Then mouseEnter and mouseLeave events will be processed
                    properly.

                    If that is not what you mean, then you willo need to provide more
                    details, like what is happening (step by step) and what you want to
                    happen (step by step)

                    Perhaps if you provided a little more of the code, we could follow it
                    and see what is going wrong. So far, all you have offered is the code
                    you use to make something invisible. How are you setting it to visible
                    again?
                    • 7. Re: visible of sprite script trouble
                      Level 7
                      OK.

                      If you make each of these dots a separate sprite from the link sprite,
                      you could use something like this on the link sprite to control the dot
                      sprite:

                      --------
                      property thisSprite
                      property dotSprite

                      on getPropertyDescriptionList
                      myPropList = [:]
                      myPropList.addProp(#dotSprite,[#comment:"enter the sprite number for
                      the dot to use:",#format:#integer,#default:""])
                      return myPropList
                      end

                      on beginSprite me
                      thisSprite = me.spriteNum
                      sprite(dotSprite).visible = false
                      end

                      on endSprite me
                      sprite(dotSprite).visible = true
                      end

                      on mouseEnter me
                      sprite(dotSprite).visible = true
                      end

                      on mouseLeave me
                      sprite(dotSprite).visible = false
                      end
                      ---------

                      alternately, you could toggle the blend between 0 and 100. Either will
                      do the same thing.

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

                      http://www.macromedia.com/software/trial/
                      • 8. Re: visible of sprite script trouble
                        eoinie Level 1
                        Hi
                        It worked a treat. Thanks so much to you both for all the help

                        Eoin