home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 2
/
boot-disc-1996-10.iso
/
bootcd.dir
/
00300_Script_RolloverClass
< prev
next >
Wrap
Text File
|
1996-08-09
|
8KB
|
251 lines
property btnlist,activesprite,lastsprite,prefix,lastframe,msglist,btnmode
property downtime,pending,initflag,btnsound,lastbtn
-- btnlist- This database has the following structure:
--[#sprite:
-- [#basecast:basecast,#basecastname:basecastname,#locast:locast,
-- #hicast:hicast,#downcast:downcast,#curcast:curcast],..]
-- where #sprite is the sprite associated with the button
-- #basecast = the default inactive cast member of the button
-- #locast = the lowest state of the hilite animation
-- #hicast = the highest state of the hilite animation
-- #downcast = the down state of the button
-- #curcast = the current cast member
-- msglist -- This database contains all of the messages from
-- the field "msglisttext", keyed to the basecast name
-- btnmode -- This describes the behavior of the button upon rollover:
-- #loop -- (default) the button loops around when it reaches the
-- end of the animation.
-- #pop -- the button will run through the animation sequence once
-- and stop on the last frame (not yet implemented).
on new me,myPrefix,mybtnmode
-- the default prefix to be looked for is "rb_" but any prefix can
-- be used if multiple collections of buttons are used.
if voidP(mybtnmode) then
set btnmode=#loop
else
set btnmode=#mybtnmode
end if
if voidP(myPrefix) then
set prefix="rb_"
else
set prefix=myPrefix
end if
set btnlist=[:]
set activesprite=0
set lastsprite=0
set lastframe=0
set lastbtn=0
set btnsound=""
global gStatus
set msglist=gStatus
-- The following removes any old instances of the RolloverClass that
-- has the same prefix, then adds the current instance to the
-- actorlist.
set olddelimiter=the itemdelimiter
set the itemdelimiter=quote
repeat with obj in the actorlist
if (item 2 of string(obj))="RolloverClass" then
if the prefix of obj=prefix then
set pos=getpos(the actorlist,obj)
deleteat the actorlist,pos
end if
end if
end repeat
set the itemdelimiter=olddelimiter
add the actorlist,me
set pending=false
set downtime=false
set initflag=true
return me
end
on stepframe me
if initflag then
init me
set initflag=false
end if
if downtime=0 then
query me
else
queryReset me
end if
-- updateStage
end
on init me
repeat with spritenum=1 to 48
if the membernum of sprite spritenum>0 then
set basecast=the membernum of sprite spritenum
set basecastname=the name of member basecast
if (char 1 to length(prefix) of basecastname)=prefix then
set btn=[:]
addprop btn,#basecast,basecast
addprop btn,#basecastname,basecastname
set locast=the number of member (basecastname&"1")
if locast<1 then
set locast=basecast
set hicast=basecast
else
repeat with index=1 to 100
if (the number of member (basecastname&index))<1 then
set hicast=the number of member (basecastname&(index-1))
set index=101
end if
end repeat
end if
addprop btn,#locast,locast
addprop btn,#hicast,hicast
addprop btn,#curcast,basecast
set downcast=the number of member (basecastname&"Down")
addprop btn,#downcast,downcast
addprop btnlist,spritenum,btn
set the membernum of sprite spritenum to basecast
puppetsprite spritenum,true
updateStage
end if
end if
end repeat
set lastbtn=0
set activesprite=0
set lastsprite=0
set lastframe=the frame
set downtime=0
set initflag=false
end init
on reset me
repeat with spritepos=1 to count(btnlist)
set spritenum=getpropat(btnlist,spritepos)
set btn=getprop(btnlist,spritenum)
set the membernum of sprite spritenum to the basecast of btn
updateStage
puppetsprite spritenum,false
end repeat
set btnlist=[:]
set activesprite=0
set lastsprite=0
set downtime=the ticks
set pending=false
end
on queryReset me
global gStatus
status gStatus
if the ticks-downtime>30 then
set initflag=true
end if
end
on query me
global gStatus
if the frame<>lastframe then
set lastframe=the frame
reset me
exit
end if
set spritefound=false
if count(btnlist)=0 then
set downtime=the ticks
exit
end if
repeat with spritepos=1 to count(btnlist)
set spritenum=getpropat(btnlist,spritepos)
set btn=getprop(btnlist,spritenum)
if rollover(spritenum) then
set spritefound=true
if not (the mousedown) then
if pending=true then
reset me
set pending=false
exit
end if
if the curcast of btn=the basecast of btn then
set the curcast of btn to the locast of btn
trace me,spritenum
else
case btnmode of
#loop:
set the curcast of btn to the curcast of btn+1
if the curcast of btn>the hicast of btn then
set the curcast of btn to the locast of btn
end if
end case
end if
set the membernum of sprite spritenum to the curcast of btn
status gStatus,the basecastname of btn
else
if the curcast of btn<>the downcast of btn then
if btnsound<>"" then
puppetSound btnsound
end if
set the curcast of btn to the downcast of btn
set the membernum of sprite spritenum to the curcast of btn
set pending=true
end if
end if
else
if the curcast of btn<>the basecast of btn then
set the curcast of btn=the basecast of btn
set the membernum of sprite spritenum to the curcast of btn
set lastbtn=spritenum
end if
end if
end repeat
if not spritefound then status gStatus
updateStage
end
on dispose me
-- The following removes any old instances of the RolloverClass that
-- has the same prefix, then adds the current instance to the
-- actorlist.
repeat with index=1 to count(btnlist)
set spritenum=getpropat(btnlist,index)
set the membernum of sprite spritenum to the basecast of getprop(btnlist,spritenum)
updateStage
puppetsprite spritenum,false
end repeat
updateStage
set olddelimiter=the itemdelimiter
set the itemdelimiter=quote
repeat with obj in the actorlist
if (item 2 of string(obj))="RolloverClass" then
if the prefix of obj=prefix then
set pos=getpos(the actorlist,obj)
deleteat the actorlist,pos
end if
end if
end repeat
set the itemdelimiter=olddelimiter
end
on trace me,spritenum
if lastbtn>0 then
puppetsound "LED0"&string(random(5))&".AIF",4
set tracesprite=castsprite("tracer")
set oldposH=the locH of sprite lastbtn
set oldposV=the locV of sprite lastbtn
set curposH=the locH of sprite spritenum
set curposV=the locV of sprite spritenum
set the visible of sprite tracesprite to true
puppetsprite tracesprite,true
set the locV of sprite tracesprite to oldposV
repeat with index=0 to 100
set the locH of sprite tracesprite to oldposH+(curposH-oldposH)*index/100
updateStage
end repeat
set the locH of sprite tracesprite to curposH
repeat with index=0 to 100
set the locv of sprite tracesprite to oldposv+(curposv-oldposv)*index/100
updateStage
end repeat
puppetsprite tracesprite,false
set the visible of sprite tracesprite to false
end if
end