Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
cXtraShapeWindow
Live Video
Drop Shadow Static-Alphamania
Simple file open/save dialog behavior
Composite Xtra
Eat That Dot
Change Filled property of a Shape Sprite
FAQ Page
Fill Gradient to a Vector Shape
Set Sound Property of a Flash member
 

 

 

Behavior Scroll Thumb

Added on 6/7/1999

 

Compatibilities:
behavior D6_5 Mac PC

Rating:

Author: PatMcClellan

For use with the , Scroll Button, Scroll Thumb Track, and the Scrollable Sprites behaviors This behavior allows the author to select direction for which the thumb (sprite) which will move when called by the ScrollButton behavior. It uses a global variable which is incremented by the ScrollButton behavior.

property pMyDirection    -- options are Horizontal and Vertical
property pMyRange        -- number of pixels that the thumb sprite may move
property pMyStartV       -- initial locV of the thumb sprite
property pMyStartH       -- initial locH of the thumb sprite
global gScrollV          -- amount scroll has been incremented Vertically from initial value
global gScrollH          -- amount scroll has been incremented Horizontally from initial value

on getPropertyDescriptionList
  set directionList = [#HORIZONTAL, #VERTICAL]
  set p_list = [
  #pMyDirection: [ #comment:   "Direction of Button Arrow",
  #format:   #symbol,
  #range:    directionList,
  #default:   #VERTICAL],
  #pMyRange:    [ #comment:   "Range of motion (in pixels)",
  #format:   #integer,
  #default:   100]
  ]
  return p_list
end

on beginSprite me
  if pMyDirection = #HORIZONTAL then
    sendAllSprites (#setThumbH, pMyRange, the spriteNum of me)
    set pMyStartH = the locH of sprite the spriteNum of me
    if gScrollH < pMyRange then
      set the locH of sprite the spriteNum of me = pMyStartH + gScrollH
    else
      set the locH of sprite the spriteNum of me = pMyStartH + pMyRange
    end if
  else
    sendAllSprites (#setThumbV, pMyRange, the spriteNum of me)
    beep
    set pMyStartV = the locV of sprite the spriteNum of me
    if gScrollV < pMyRange then
      set the locV of sprite the spriteNum of me = pMyStartV + gScrollV
    else
      set the locV of sprite the spriteNum of me = pMyStartV + pMyRange
    end if
  end if
end

on scrollThumbH me
  if pMyDirection = #HORIZONTAL then
    set the locH of sprite the spriteNum of me = pMyStartH + gScrollH
  end if
end

on scrollThumbV me
  if pMyDirection = #VERTICAL then
    set the locV of sprite the spriteNum of me = pMyStartV + gScrollV
  end if
end

on mouseDown me
  if pMyDirection = #VERTICAL then
    set startMouse = the mouseV
    set startScroll = gScrollV
    repeat while the stillDown and gScrollV >= 0 and gScrollV <= pMyRange
      set gScrollV = min(pMyRange, startScroll + (the mouseV - startMouse))
      set gScrollV = max (gScrollV, 0)
      set the locV of sprite the spriteNum of me = pMyStartV + gScrollV
      sendAllSprites(#ScrollV)
      updateStage
    end repeat
  else
    set startMouse = the mouseH
    set startScroll = gScrollH
    repeat while the stillDown and gScrollH >= 0 and gScrollH <= pMyRange
      set gScrollH = min (pMyRange,startScroll + (the mouseH - startMouse))
      set gScrollH = max(gScrollH, 0)
      set the locH of sprite the spriteNum of me = pMyStartH + gScrollH
      sendAllSprites(#ScrollH)
      updateStage
    end repeat
  end if
end  

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail