home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 9
/
boot-disc-1997-05.iso
/
Media
/
backup
/
Demos.dxr
/
00056_Field_56.txt
< prev
next >
Wrap
Text File
|
1997-02-10
|
15KB
|
343 lines
--on startmovie
-- global gScroller, gscroller2, gscroller3
-- set gScroller to birth(script "scrollParent", 3, 2, 1, 4, 20, 12, 14)
-- set gScroller2 to birth(script "scrollParent", 11, 9, 8, 10, 19, 12, 18)
-- set gScroller3 to birth(script "scrollParent", 14, 16, 15, 17, 18, 12, 9)
-- set the actorlist = [gScroller3, gScroller2, gScroller]
--end
--
--Parameters..........
--TopArrowSprite, BottomArrowSprite, BarSprite, SliderBoxSprite, TextField, textSource, PageStep
--
---------------------------------------------------------------------
--on stopMovie
-- put " " into field 18
-- put " " into field 19
-- put " " into field 20
--end
--SCROLL BAR PARENT SCRIPT -- ACTORLIST VERSION .............
--© Yair Sageev, 1995 ... not really a copyrite--it just means I wrote it. };->
--My custom scrollbar attempts to mimic that standard Macintosh scrollbar
--in every way, except that it doesn't have a ghost rect on the draggable
--box. Rather, it (more-or-less) scrolls in real time with the drag (a-la X-Windows).
--
--This version utilizes the
--actorlist to handle stage updates. Thus, it allows other processes
--to execute. However, I have a (barely) faster version that
--utilizes repeat loops, but does not allow anything else to happen
--while scrolling. Anyways, the speed of scrolling is dependent up
--the tempo of your movie and the amount of other stuff going on.
--For maximum thrills, run the script at a tempo of 120 fps on a
--power mac.
--
--remember to put all instances in the actorlist.
--
--Attach dummy mouseup scripts to the respective
--sprites or cast members. Otherwise, everything is taken care of
--for you here. Just put a fixed text field on stage, position
--four pieces of artwork accordingly, and pass their sprite numbers
--in the birth statement.
--
--Unfortunately, Director defines a line to be a chunk of text
--delimited by a carriage return, so the scrollbar requires that
--each line (as we think of it) finish with a return -- Yair
---------------------------------------------------------------------
---------------------------------------------------------------------
property pTopLine, pBottomLine, pLineCount, pPageStep, pUpFlag
property pHalfHeight, pBarHeight, pLineStep, pCounter, pScrollJump, pTopPosition
property pBottomPosition, pDownArrowTop, pTopArrowBot, gRightBoundary, pBarFlag
property pLeftBoundary, pShortFlag, pTextField, pTextSource, pHandlerList,
property pTopArrowSprite, pBottomArrowSprite, pBarSprite, pSliderBoxSprite
property pCounterStore, pReallyOldLocV, pStillDownFlag, pStepFrameDownFlag,
property pRestoreFlag, pSlideFlag, pSpritePropList, pRepeatNum, pMouseDiff
global gVeryLongRepeatFlag --speeds responsiveness (barely) if you have multiple scrollBars on stage
------------------- at the same time. If you only have one, you may make this a property.
--I decided to factor out the the constant sprite positions and
--pixel distances (e.g. "the locV of sprite x", pHalfHeight) into
--properties, because I figured it would be faster to simply
--reference a variable each time than to get sprite info constantly.
--In addition, because the object depends on the stepframe, local variables
--don't maintain their values over repeated executions. So they needed to
--be turned into (static) property variables as well.
--All this accounts for the rather large
--number of property variables. If you need the scroll bar to
--update to different sizes or to correspond to different text
--sources throughout the movie, then the
--strategy is to call the birthed object's "init" method when an
--update is needed.
---------------------------------------------------------------------
--PARAMETERS:
--topArrowSprite = the sprite associated with the top arrow
--BottomArrowSprite = the sprite associated with the bottom arrow
--BarSprite = the sprite associated with the bar
--SliderBoxSprite = the sprite associated with the draggable box
--TextField = the field on stage which recieves text chunks
--TextSource = the source field of text
--pageStep = the number of lines that are visible at any one time in the field
--
--If you don't know how to birth objects, simply add the following line of code to your movie:
--on makeScrollBar
-- global gscroller
-- set gscroller = birth(script "scrollParent", [parameters])
-- add (the actorlist, gScroller)
--end makeScrollBar
on birth me, TopArrowSprite, BottomArrowSprite, BarSprite, SliderBoxSprite, TextField, textSource, pagestep
set pTopArrowSprite = TopArrowSprite
set pBottomArrowSprite = BottomArrowSprite
set pBarSprite = BarSprite
set pSliderBoxSprite = SliderBoxSprite
set pTextField = TextField
put field textSource into pTextSource
set pPageStep = pagestep
set pHandlerList = ["DownButtonMouseDown me", "TopButtonMouseDown me", "BarMouseDown me", "SliderMouseDown me"]
set pSpritePropList = [ pBottomArrowSprite, pTopArrowSprite, pBarSprite, pSliderBoxSprite]
repeat with x in pSpritePropList
puppetSprite (x), TRUE
end repeat
init me
return me
end birth
---------------------------------------------------------------------
on init me
put the number of lines of pTextSource into pLineCount
set pTopLine = 1
set pBottomLine = pPageStep
put line pTopLine to pBottomLine of pTextSource into field pTextField
if pLineCount <= pPageStep then
set pShortFlag = TRUE
--What follows is merely a default. You can do whatever you want right
--here (switch castmembers, do the hokey pokey......).
--BEGIN DEFAULT
set the ink of sprite pBarSprite = 38
set the blend of sprite pBottomArrowSprite = 39
set the blend of sprite pTopArrowSprite = 39
set the ink of sprite pSliderBoxSprite = 39
--END DEFAULT
else
set pStepFrameDownFlag = FALSE
set pShortFlag = FALSE
set pSlideFlag = FALSE
set pBarFlag = FALSE
set pRestoreFlag = TRUE
set pStillDownFlag = TRUE
set gVeryLongRepeatFlag = FALSE
set pReallyOldLocV = 0
set pTopArrowBot = the bottom of sprite pTopArrowSprite
set pDownArrowTop = the top of sprite pBottomArrowSprite
set pLeftBoundary = (the locH of sprite pSliderBoxSprite) + 36
set gRightBoundary = (the locH of sprite pSliderBoxSprite) - 36
set pBarHeight = float(pDownArrowTop - pTopArrowBot - the height of sprite pSliderBoxSprite)
set pHalfHeight = (the bottom of sprite pSliderBoxSprite - the top of sprite pSliderBoxSprite)/2
set pTopPosition = pTopArrowBot + pHalfHeight
set the locV of sprite pSliderBoxSprite to pTopPosition
set pCounter = float(the locV of sprite pSliderBoxSprite)
set pCounterStore = pCounter
set pBottomPosition = pDownArrowTop - pHalfHeight
set pLineStep = float(pBarHeight)/(float(pLineCount) - float(pPageStep))
set pScrollJump = float(pBarHeight)/((float(pLineCount) - float(pPageStep))/float(pPageStep))
end if
end init
---------------------------------------------------------------------
on stepFrame me
if pshortFlag = FALSE then
if the stilldown then
set pStillDownFlag = FALSE
if gVeryLongRepeatFlag = FALSE then
repeat with pRepeatNum = 1 to 4
if getaprop(pSpritePropList, pRepeatNum) = the clickon then
set pStepFrameDownFlag = TRUE
set gVeryLongRepeatFlag = TRUE
exit repeat
end if
end repeat
end if
if pStepFrameDownFlag then
do getaprop(pHandlerList, pRepeatNum)
end if
else if pStillDownFlag = FALSE then
set pStillDownFlag = TRUE
if gVeryLongRepeatFlag = TRUE then
set the ink of sprite (the clickon) = 0
set gVeryLongRepeatFlag = FALSE
end if
set pStepFrameDownFlag = FALSE
set pSlideFlag = FALSE
set pBarFlag = FALSE
if pRestoreFlag = FALSE then
restoreMySlider
end if
end if
end if
end stepframe
---------------------------------------------------------------------
on restoreMySlider me
set pCounter = pCounterStore
set temp = (the locV of sprite pSliderBoxSprite - pReallyOldLocV)
set proportion = abs((the locV of sprite pSliderBoxSprite - pReallyOldLocV)/pBarHeight)
set scrollAmount = (pLineCount - pPageStep) * proportion
set the locV of sprite pSliderBoxSprite = pReallyOldLocV
set pRestoreFlag = TRUE
if temp < 0 then
scroll me, "down", scrollAmount
else if temp > 0 then
scroll me, "up", scrollAmount
end if
set the ink of sprite pSliderBoxSprite to 0
end restoreMySlider
---------------------------------------------------------------------
on BarMouseDown me
if pShortFlag = FALSE then
if pBarFlag = FALSE then
if the mouseV < (the top of sprite pSliderBoxSprite) then
set pUpFlag = TRUE
else if the mouseV > (the bottom of sprite pSliderBoxSprite) then
set pUpFlag = FALSE
end if
set pBarFlag = TRUE
end if
if rollover (pBarSprite) then
if (pUpFlag AND (the mouseV < pcounter - phalfheight)) then
if ((pcounter - phalfheight - pScrollJump) < pTopArrowBot) then
set the locV of sprite pSliderBoxSprite = pTopPosition
set pCounter = pTopPosition
scroll me, "up", pPageStep
else
set pCounter = pCounter - pScrollJump
set the locV of sprite pSliderBoxSprite = pCounter
scroll me, "up", pPageStep
end if
else if ((pUpFlag = FALSE) AND (the mouseV > pcounter + phalfheight)) then
if ((pcounter + phalfheight + pScrollJump) > pDownArrowTop) then
set the locV of sprite pSliderBoxSprite = pBottomPosition
set pCounter = pBottomPosition
scroll me, "down", pPageStep
else
set pCounter = pCounter + pScrollJump
set the locv of sprite pSliderBoxSprite = pCounter
scroll me, "down", pPageStep
end if
end if
end if
end if
end BarMouseDown
---------------------------------------------------------------------
on DownButtonMouseDown me
if pShortFlag = FALSE then
if rollover (pBottomArrowSprite) then
set the ink of sprite pBottomArrowSprite to 36
if pBottomLine <> pLineCount then
if pDownArrowTop - (the bottom of sprite pSliderBoxSprite) > pLineStep then
set pCounter = pCounter + pLineStep
set the locV of Sprite pSliderBoxSprite = pCounter
scroll me, "down", 1
else
scroll me, "down", 1
end if
else
set the locv of sprite pSliderBoxSprite = pBottomPosition
set pCounter = pBottomPosition
end if
else
set the ink of sprite pBottomArrowSprite to 0
end if
end if
end DownButtonMouseDown
---------------------------------------------------------------------
on TopButtonMouseDown me
if pShortFlag = FALSE then
if rollover (pTopArrowSprite) then
set the ink of sprite pTopArrowSprite to 36
if pTopLine <> 1 then
if (the top of sprite pSliderBoxSprite) - pTopArrowBot > pLineStep then
set pCounter = pCounter - pLineStep
set the locV of Sprite pSliderBoxSprite = pCounter
scroll me, "up", 1
else
scroll me, "up", 1
end if
else
set the locv of sprite pSliderBoxSprite = pTopPosition
set pCounter = pTopPosition
end if
else
set the ink of sprite pTopArrowSprite to 0
end if
end if
end TopButtonMouseDown
---------------------------------------------------------------------
on SliderMouseDown me
if pShortFlag = FALSE then
if (pSlideFlag = FALSE) then
set pMouseDiff = (the mouseV - the locv of sprite pSliderBoxSprite)
set pReallyOldLocV = the locV of sprite pSliderBoxSprite
put pCounter into PCounterStore
set pSlideFlag = TRUE
end if
if (the mouseH > gRightBoundary) AND (the MouseH < pLeftBoundary) then
set pRestoreFlag = TRUE
set the ink of sprite pSliderBoxSprite to 0
set oldLocV = the locV of sprite pSliderBoxSprite
if (the mouseV - pMouseDiff + pHalfHeight) > pDownArrowTop then
set the locv of sprite pSliderBoxSprite = pBottomPosition
set pCounter = pBottomPosition
set pBottomLine = pLineCount
scroll me, "down", 1
else if (the mouseV - pMouseDiff - pHalfHeight) < pTopArrowBot then
set the locv of sprite pSliderBoxSprite = pTopPosition
set pCounter = pTopPosition
set pTopLine = 1
scroll me, "up", 1
else
set the locv of sprite pSliderBoxSprite = the mouseV - pMouseDiff
set temp = the locV of sprite pSliderBoxSprite - oldLocV
set proportion = abs((the locV of sprite pSliderBoxSprite - oldLocV)/pBarHeight)
set scrollAmount = (pLineCount - pPageStep) * proportion
set pCounter = pCounter + temp
if temp > 0 then
scroll me, "down", scrollAmount
else if temp < 0 then
scroll me, "up", scrollAmount
end if
end if
else
set pRestoreFlag = FALSE
--BEGIN DEFAULT
set the ink of sprite pSliderBoxSprite to 39
--END DEFAULT
end if
end if
end SliderBoxMouseDown
---------------------------------------------------------------------
on scroll me, UpOrDown, howMuch
if UpOrDown = "Down" then
if pBottomLine + howMuch <= pLineCount then
set pBottomLine = pBottomLine + howMuch
set pTopLine = pTopLine + howMuch
put line pTopLine to pBottomLine of pTextSource into field pTextField
else
set pBottomLine = pLineCount
set pTopLine = pBottomLine - pPageStep
put line pTopLine to pBottomLine of pTextSource into field pTextField
end if
else if UpOrDown = "Up" then
if pTopLine - howMuch > 0 then
set pTopLine = pTopLine - howMuch
set pBottomLine = pBottomLine - howMuch
put line pTopLine to pBottomLine of pTextSource into field pTextField
else
set pTopLine = 1
set pBottomLine = pPageStep
put line pTopLine to pBottomLine of pTextSource into field pTextField
end if
end if
end scroll
---------------------------------------------------------------------