0 Replies Latest reply on Apr 18, 2013 5:09 AM by anjemalo

    Slider images with ease

    anjemalo Level 1

      Hello:

       

      I'm using the "HorizontalImageSlider.Behaviour" get it from www.lingoworkshop.com on the Slider_tut.dir file.

      I have to try to get easing effect with this but I dónt know where to put the code for this and what code is.

      I have commented on Enterframe the part where is the slide, only for drag.

       

      Can you help me please?

      Thank you very much.

       

      This is the code:

       

      property ancestor

      property myMidH, myShift, myAlpha, myOffset

      property myTrackingFlag, myStartH

      property mySlideLeftRect, mySlideRightRect

       

      on beginSprite me

          thisSprite = sprite(me.spriteNum)

        thisRect = thisSprite.rect

        thisMember = thisSprite.member

        thisCanvas = thisMember.image

        thisCanvas.fill(thisCanvas.rect, rgb("#000000"))

          --

        myOffset = point(thisRect.left, thisRect.top)

        myMidH = thisSprite.left + (thisSprite.width/2)

          -- get a list on images to show

        fndImages = me._GetImages()

          -- create the slider object

        ancestor = script("HorizontalImageSlider.Class").new()

        me.Initialise(thisCanvas, thisCanvas.rect)

        me.LoadImages(fndImages)

          -- create the 'hot spots' for sliding

        mySlideLeftRect = rect(thisSprite.left, thisSprite.top, thisSprite.left + (thisSprite.width/3), thisSprite.bottom)

        mySlideRightRect = rect(thisSprite.right-(thisSprite.width/3), thisSprite.top, thisSprite.right, thisSprite.bottom)

       

      end

       

      on endSprite (me)

        -- clean up the canvas

        thisSprite = sprite(me.spriteNum)

        thisMember = thisSprite.member

        thisCanvas = thisMember.image

        thisCanvas.fill(thisCanvas.rect, rgb("#000000"))

      end   

       

       

      on enterframe (me)

        if myTrackingFlag then

          -- the mouse was clicked on this sprite

          if not (the mouseDown) then

            -- stop tracking

            ----------------------------------------------------- myTrackingFlag = 0

          else

            -- 'drag' the slider to the current mouse location

            mH = the mouseH

            amt = myStartH - mH

            myStartH = mH

            me.Slide(amt)

          end if

        else

          p = the mouseLoc

          if inside(p, mySlideLeftRect) then

           

            -------------------------------------------------------------I remove this code only need Drag

            --------------------------      proposedAmt =  myShift -1

            --------------------------      myShift = Max(-50, proposedAmt)

           

            --------------------------   else  if inside(p, mySlideRightRect) then

            --------------------------      proposedAmt =  myShift + 1

            --------------------------      myShift = Min(50, proposedAmt)

           

          else

            -- slow down to a stop

            myShift = myShift * 0.75

            if abs(myShift) < 2 then myShift = 0

          end if

          me.Slide(myShift)

        end if

      end

       

      on mouseDown (me)

        ClickedTile = me.GetTileAtPoint(the mouseLoc - myOffset)

        if voidP(ClickedTile) then return

        myTrackingFlag = 1

        myShift= 0

        myStartH = the mouseH

        me.SelectTile(ClickedTile, (the shiftDown))

        PUT ""& ClickedTile   --AML

      end

       

       

      on _GetImages (me)

       

        fnd = []

        mx = (the number of members of castlib "Images")

        repeat with i = 1 to mx

          m = member(i, "Images")

          fnd.append(m)

         

        end repeat

        return fnd

       

      end