5 Replies Latest reply on Jul 7, 2006 1:33 PM by Newsgroup_User

    thumbnails

    oreopeewee Level 1
      I have a thumbnail of 10 images and I need to be able to mouse over each thumbnail and have the larger image appear in a certain area. Could someone tell me how to do this?

      thanks
        • 1. Re: thumbnails
          Level 7
          I'm guessing that you mean that you have one large image that shows 10
          smaller images. If that's the case, then you could:

          1. Cut up the large image into 10 smaller images and use each of those
          as an individual cast member,
          2. Place borderless, unfilled shapes over or under the one large image
          sprite,
          3. Write a function that tracks the location of the cursor when it is
          over the large image sprite, then use this location to parse out which
          image the cursor is over.

          1 could be done in Photoshop/ImageReady in seconds and each slice could
          be imported into Director. 2 could also be done in, well, minutes. 3 is
          just stupid.

          Or were you asking about showing the new, larger image?

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

          http://www.macromedia.com/software/trial/
          • 2. Re: thumbnails
            oreopeewee Level 1
            Sorry, that's not what I mean. I will try and explain. I have 10 pictures and each picture has a thumbnail. I would like to be able to show the thumbnails and when I mouse over each thumbnail the larger version of that thumbnail shows up. When I move the mouse away from that thumbnail the larger picture would go away. Here is the code I used.

            on mouseEnter
            --Set the 'loc' property of the sprite to somewhere in the viewable area of the stage.
            --The 'loc' value is set and got by the 'regPoint' of the sprite.
            sprite(8).loc = point(344, 140)
            end

            on mouseLeave
            --Set the 'loc' property of the sprite back to the nonviewable area
            sprite(8).loc = point(-100, -100)
            end

            This works fine with only one image, when I try to use this for the second thumbnail only the second will work and the first won't. I have ten images and ten thumbnails.

            thanks so much for your help
            • 3. Re: thumbnails
              oreopeewee Level 1
              Addendum. The above code works but only with one image. Since I have 10 images I am putting each in a seperate channel one underneath the next is that my problem?
              • 4. Re: thumbnails
                Level 7
                > on mouseEnter
                > --Set the 'loc' property of the sprite to somewhere in the viewable area of
                > the stage.
                > --The 'loc' value is set and got by the 'regPoint' of the sprite.
                > sprite(8).loc = point(344, 140)
                > end
                >
                > on mouseLeave
                > --Set the 'loc' property of the sprite back to the nonviewable area
                > sprite(8).loc = point(-100, -100)
                > end

                Like Rob, I'm a little unclear what you're trying to achieve - or
                rather, how you're going about it - but my guess would be that you're
                trying to reuse the same behavior on all of your thumbnail sprites and
                have each thumbnail display a different sprite.
                If this is the case, then the #getPropertyDescriptionList handler is
                your window to re-useable code.

                My inclination would be to use 2 behaviors, one of which talks to the
                other. I would lay each of the expanded or full-sized images out on the
                stage, positioned where I'd like them to appear when shown, and attach
                the following behavior to them:
                --
                property spriteNum
                property my
                property myLoc

                on beginSprite me
                my = sprite(spriteNum)
                myLoc = my.loc
                me.mHide()
                end

                on mHide me
                my.loc = myLoc + 10000
                end

                on mShow me
                my.loc = myLoc
                end
                --
                and then attach something like the following to the thumbnail sprites:
                --
                property myTargetSprite

                on getPropertyDescriptionList
                pdl = [:]

                tItem = [:]
                tItem[#comment] = "Target sprite:"
                tItem[#format] = #integer
                tItem[#default] = the currentSpriteNum + 10 -- alter to suit
                tItem[#range] = [#min: 1, #max: the lastChannel]

                pdl[#myTargetSprite] = tItem

                return pdl
                end

                on mouseEnter me
                sendSprite(myTargetSprite, #mShow)
                end

                on mouseLeave me
                sendSprite(myTargetSprite, #mHide)
                end
                • 5. Re: thumbnails
                  Level 7
                  oreopeewee wrote:
                  > Sorry, that's not what I mean. I will try and explain. I have 10 pictures and
                  > each picture has a thumbnail. I would like to be able to show the thumbnails
                  > and when I mouse over each thumbnail the larger version of that thumbnail shows
                  > up. When I move the mouse away from that thumbnail the larger picture would go
                  > away. Here is the code I used.

                  Try this:
                  1. use a named policy for your cast members: if a thumbnail cast member name is
                  "flower", named the cast member with full image of flower "flower_big" and so on

                  2. attach this beahviour on all yours thumbnail sprites:

                  property mySprite, pTargetName

                  on beginSprite me
                  mySprite = sprite(me.spriteNum)
                  ptargetName = mySprite.member.name&"_big"
                  end

                  on mouseEnter me
                  sendAllSprites(#switchThumb, pTargetName, 1)
                  end

                  on mouseLeave me
                  sendAllSprites(#switchThumb, pTargetName, 0)
                  end


                  3. place all big pitcures on the stage, each one on a different sprite channel.
                  Place them exactly in the point you wont show them

                  4. attach this behaviour on all big picturse sprites:

                  property mySprite, myName, myDisableLocH

                  on beginSprite me
                  mySprite = sprite(me.spriteNum)
                  myName = mySprite.member.name
                  myDisableLocH = mySprite.locH + 2000
                  switchThumb me, myName, 0
                  end

                  on switchThumb me, theName, theFlag
                  if theName = myName then
                  mySprite.locH = myDisableLocH - (2000 * theFlag)
                  else
                  mySprite.locH = myDisableLocH
                  end if
                  end


                  Of course, you can use only one sprite channel for yours big pictures and simply
                  change the "member" channel propriety when call switchThumb method. In this
                  case, attach this one on your big pictures:


                  property mySprite, myDisableLocH

                  on beginSprite me
                  mySprite = sprite(me.spriteNum)
                  myDisableLocH = mySprite.locH + 2000
                  switchThumb me, "", 0
                  end

                  on switchThumb me, theName, theFlag
                  if theFlag then mySprite.member = member(theName)
                  mySprite.locH = myDisableLocH - (2000 * theFlag)
                  end


                  However, remember that you should have to check if member(theName) still exists
                  and is a #bitmap before starting switchThumb method:


                  on switchThumb me, theName, theFlag
                  isBitmap = 0
                  if member(theName).number > 0 then
                  if member(theName).type = #bitmap then
                  mySprite.member = member(theName)
                  isBitmap = 1
                  end if
                  end if
                  mySprite.locH = myDisableLocH - (2000 * theFlag * isBitmap)
                  end

                  just a little more complex, but more secure ;)

                  Hope this help
                  asleo