home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 2
/
boot-disc-1996-10.iso
/
Demo.dir
/
00048_Script_scrollClass
< prev
next >
Wrap
Text File
|
1996-08-09
|
11KB
|
348 lines
property revSprite,advSprite,revBtnUp,revBtnDn,advBtnUp,advBtnDn
property thumbSprite,thumbOrient,thumbpos,thumbmin,thumbmax
property textmember,textsprite,numLines,texttop,textHeight
property totalTextHeight,curLine,textRate,textDefaultRate
property RevActive,AdvActive,ThumbActive,IDName,thumbRefresh
property textdelta,basepos,acceleratemode,hand,handmask
property findinstance,findtext
on new me,myIDName,textMemberName,revMemberName,advMemberName,thumbName,tOrient,tMin,tMax,handmember,handmaskmember
set IDName=myIDName
do ("global "&IDName)
do ("set "&IDName&" to me")
set revSprite=castsprite(me,revMemberName)
set advSprite=castsprite(me,advMemberName)
set revBtnUp=the number of member revMemberName
set revBtnDn=the number of member (revMemberName&"Down")
set advBtnUp=the number of member advMemberName
set advBtnDn=the number of member (advMemberName&"Down")
preload advBtnDn
preload revBtnDn
set findtext=""
set textDefaultRate=5
set textRate=textDefaultRate
set thumbSprite=castsprite(me,thumbName)
set thumbOrient=tOrient
set thumbMin=tMin
set thumbMax=tMax
puppetsprite thumbSprite,true
puppetsprite revsprite,true
puppetsprite advsprite,true
set textMember=the number of member textMemberName
set textsprite=castsprite(me,textMemberName)
setTextCursor me,hand,handmask
set textdelta=0
set numLines=the linecount of member textmember
if the number of member "SystemInfoList">0 then
set syslist=value(the text of member "SystemInfoList")
if not listP(syslist) then
set totalTextHeight=getTextHeight(me,numLines)
else
set obj=getaprop(syslist,IDName)
if not voidP(obj) then
set totalTextHeight=the totalTextHeight of obj
else
set totalTextHeight=getTextHeight(me,numLines)
end if
end if
else
set totalTextHeight=getTextHeight(me,numLines)
end if
set textTop=the locV of sprite textsprite
set textHeight=the height of sprite textsprite
set curline=1
set thumbrefresh=false
set the scrolltop of member textMember to 0
set acceleratemode=false
updateThumb me
clearOldInstancesOf me
add the actorlist,me
updateSystemInfoList me
return me
end
on clearOldInstancesOf me
set clearlist=[]
set oldDelimiter=the itemDelimiter
set the itemDelimiter=quote
repeat with obj in the actorlist
if item 2 of string(obj)="scrollClass" then
if the textmember of obj=textmember then
add clearlist,getpos(the actorlist,obj)
end if
end if
end repeat
repeat with index=count(clearlist) down to 1
set curpos=getat(clearlist,index)
deleteat the actorlist,curpos
end repeat
set the itemDelimiter=oldDelimiter
end
on getTextHeight me,numlines
if voidP(numlines) then set numlines=the linecount of member textmember
set pos=0
repeat with index=1 to numlines
set pos=pos+the lineheight of line index of member textmember
end repeat
return pos
end
on castsprite me,castname
set spritenum=0
repeat with index=1 to 48
if the membernum of sprite index>0 then
if the name of member the membernum of sprite index=castname then
set spritenum=index
exit repeat
end if
end if
end repeat
return spritenum
end castsprite
on stepframe me
set refreshmode=true
if the mouseDown then
if rollover(thumbSprite) or (thumbrefresh) then
if thumbOrient=#vert then
set the locV of sprite thumbsprite to min(max(the mouseV,thumbmin),thumbmax)
else
set the locH of sprite thumbsprite to min(max(the mouseH,thumbmin),thumbmax)
end if
updateStage
set thumbrefresh=true
setTextFromThumb me
end if
end if
if the mousedown then
if rollover(textsprite) then
if textdelta=0 then
set textdelta=the mouseV
set basepos=the scrolltop of member textmember
end if
if the rightmousedown then
set basepos=the scrolltop of member textmember
end if
set the scrolltop of member textmember to min(max(basepos+textdelta-the mouseV,0),totaltextheight-textheight)
updateThumb me
end if
else
if textdelta<>0 then
set textdelta=0
-- updateThumb me
end if
end if
if the mouseUp and thumbrefresh=true then
set thumbrefresh=false
setTextFromThumb me
end if
if rollover(advSprite) then
if the mousedown then
if the membernum of sprite advSprite=advbtnup then
set the membernum of sprite advSprite to advbtndn
updateStage
end if
set refreshmode=false
advance me
end if
end if
if rollover(revSprite) then
if the mousedown then
if the membernum of sprite revSprite=revbtnup then
set the membernum of sprite revSprite to revbtndn
updateStage
end if
set refreshmode=false
reverse me
end if
end if
if refreshmode then
set textrate=textdefaultrate
if the membernum of sprite revsprite=revbtndn then
set the membernum of sprite revsprite to revbtnup
updateStage
end if
if the membernum of sprite advsprite=advbtndn then
set the membernum of sprite advsprite to advbtnup
updateStage
end if
end if
end
on setTextFromThumb me
-- cursor 4
if thumborient=#vert then
set ratio=1.0*(the locV of sprite thumbsprite-thumbmin)/(thumbmax-thumbmin)
set the scrollTop of member textmember to integer((totaltextheight-textheight)*ratio)
else
set ratio=1.0*(the locH of sprite thumbsprite-thumbmin)/(thumbmax-thumbmin)
set the scrollTop of member textmember to integer((totaltextheight-textheight)*ratio)
-- set curline=locVtolinepos(member textmember,texttop)
-- set newpos=gettextheight(me,curline-1)
-- set the scrollTop of member textmember to newpos
end if
-- cursor -1
end
on advance me
set textrate=the lineheight of line (locVtolinepos(member textmember,texttop)) of member textmember
if the scrollTop of member textmember+textheight+textrate<=totaltextheight then
set the scrollTop of member textmember to the scrollTop of member textmember+textrate
-- set textrate=textrate+0.2
updateThumb me
end if
end
on reverse me
set textrate=the lineheight of line (locVtolinepos(member textmember,texttop)) of member textmember
if the scrolltop of member textmember - textrate>=0 then
set the scrollTop of member textmember to the scrollTop of member textmember-textrate
--set textrate=textrate+0.2
updateThumb me
end if
end
on reset me
set totalTextHeight=gettextheight(me)
-- if totalTextHeight<textheight then
-- set the visible of sprite thumbsprite to false
-- else
-- set the visible of sprite thumbsprite to true
-- end if
updateSystemInfoList me
end
on updateThumb me
-- set totalTextHeight=gettextheight(me)
-- if totalTextHeight<textheight then
-- set the visible of sprite thumbsprite to false
-- else
-- set the visible of sprite thumbsprite to true
-- end if
set ratio=1.0*(the scrolltop of member textmember)/(totaltextheight-textheight)
if thumborient=#vert then
set the locV of sprite thumbsprite to thumbmin+ratio*(thumbmax-thumbmin)
else
set the locH of sprite thumbsprite to thumbmin+ratio*(thumbmax-thumbmin)
end if
updateStage
end
on settextcursor me,hand,handmask
if voidP(hand) then
if the number of member "hand">0 then
if the number of member "handmask">0 then
set the cursor of sprite textsprite to [the number of member "hand",the number of member "handmask"]
end if
end if
else
if the number of member hand>0 then
if the number of member handmask>0 then
set the cursor of sprite textsprite to [the number of member hand,the number of member handmask]
else
set the cursor of sprite textsprite to [the number of member hand,the number of member hand]
end if
else
alert ("The castmember "&hand&" was not found.")
halt
end if
end if
end
on dispose me
updateSystemInfoList me
clearOldInstancesOf me
puppetsprite thumbsprite,0
puppetsprite advsprite,0
puppetsprite revsprite,0
set the cursor of sprite textsprite to -1
return 0
end
on updateSystemInfoList me
set systemlist=[:]
if the number of member "SystemInfoList"<1 then
set systemlist=[:]
set sysmember=findEmpty(member 1)
repeat with index=1 to the maxInteger
if the type of member index=#field then
duplicate member index, sysmember
exit repeat
end if
end repeat
set the name of member sysmember to "SystemInfoList"
set the text of member sysmember to "[:]"
else
set sysmember=the number of member ("SystemInfoList")
set systemlist=value(the text of member sysmember)
if systemlist=0 then
set systemlist=[:]
end if
end if
set proplist=[:]
repeat with index=1 to count(me)
set prop=getpropat(me,index)
set entry=getprop(me,prop)
if voidP(entry) then set entry=0
addprop proplist,prop,entry
end repeat
if voidP(getaprop(systemlist,IDName)) then
addprop systemlist,IDName,proplist
else
setprop systemlist,IDName,proplist
end if
set the text of member sysmember to string(systemlist)
end
on find me,phrase,whichincidence
if voidP(phrase) then
if findtext="" then
alert("A search phrase must be specified")
exit
else
set phrase=findtext
end if
else
if findtext<>phrase then
set findinstance=0
end if
end if
set lastpos=0
set findtext=phrase
set curtext=the text of member TextMember
if voidP(whichincidence) then
set whichincidence=findinstance+1
set findinstance=whichincidence
else
set findinstance=whichincidence
end if
set the forecolor of member TextMember to 255
repeat with index=1 to whichincidence
set pos=offset(phrase,curtext)
if pos=0 then
if index=1 then
alert(quote&phrase"e&" was not found.")
exit
else
alert("No more instances of ""e&phrase"e&" were found.")
exit
end if
else
set curchar=pos+lastpos
set linepos=linePosToLocV(member textmember,locVToLinePos(member textmember,getat(charpostoloc(member textmember,curchar),2)+texttop)-1)-texttop
if index=whichincidence then
set the forecolor of char curchar to curchar+length(phrase)-1 of member textmember to 6
set the scrolltop of member textmember to linepos
updateThumb me
end if
set lastpos=lastpos+pos+length(phrase)-1
delete char 1 to pos+length(phrase)-1 of curtext
end if
end repeat
end