home *** CD-ROM | disk | FTP | other *** search
/ Boot Disc 2 / boot-disc-1996-10.iso / bootcd.dir / 00300_Script_RolloverClass < prev    next >
Text File  |  1996-08-09  |  8KB  |  251 lines

  1. property btnlist,activesprite,lastsprite,prefix,lastframe,msglist,btnmode
  2. property downtime,pending,initflag,btnsound,lastbtn
  3.  
  4. -- btnlist- This database has the following structure:
  5. --[#sprite:
  6. --    [#basecast:basecast,#basecastname:basecastname,#locast:locast,
  7. --           #hicast:hicast,#downcast:downcast,#curcast:curcast],..]
  8. -- where #sprite is the sprite associated with the button
  9. -- #basecast = the default inactive cast member of the button
  10. -- #locast = the lowest state of the hilite animation
  11. -- #hicast = the highest state of the hilite animation
  12. -- #downcast = the down state of the button
  13. -- #curcast = the current cast member
  14. -- msglist -- This database contains all of the messages from
  15. -- the field "msglisttext", keyed to the basecast name
  16. -- btnmode -- This describes the behavior of the button upon rollover:
  17. --    #loop -- (default) the button loops around when it reaches the
  18. --             end of the animation.
  19. --    #pop  -- the button will run through the animation sequence once
  20. --             and stop on the last frame (not yet implemented).
  21.  
  22. on new me,myPrefix,mybtnmode
  23.   -- the default prefix to be looked for is "rb_" but any prefix can
  24.   -- be used if multiple collections of buttons are used.
  25.   if voidP(mybtnmode) then
  26.     set btnmode=#loop
  27.   else
  28.     set btnmode=#mybtnmode
  29.   end if
  30.   if voidP(myPrefix) then
  31.     set prefix="rb_"
  32.   else
  33.     set prefix=myPrefix
  34.   end if
  35.   set btnlist=[:]
  36.   set activesprite=0
  37.   set lastsprite=0
  38.   set lastframe=0
  39.   set lastbtn=0
  40.   set btnsound=""
  41.   global gStatus
  42.   set msglist=gStatus
  43.   -- The following removes any old instances of the RolloverClass that
  44.   -- has the same prefix, then adds the current instance to the
  45.   -- actorlist.
  46.   set olddelimiter=the itemdelimiter
  47.   set the itemdelimiter=quote
  48.   repeat with obj in the actorlist
  49.     if (item 2 of string(obj))="RolloverClass" then
  50.       if the prefix of obj=prefix then
  51.         set pos=getpos(the actorlist,obj)
  52.         deleteat the actorlist,pos
  53.       end if
  54.     end if
  55.   end repeat
  56.   set the itemdelimiter=olddelimiter
  57.   add the actorlist,me
  58.   set pending=false
  59.   set downtime=false
  60.   set initflag=true
  61.   return me
  62. end
  63.  
  64. on stepframe me
  65.   if initflag then
  66.     init me
  67.     set initflag=false
  68.   end if
  69.   if downtime=0 then
  70.     query me
  71.   else      
  72.     queryReset me
  73.   end if
  74.   -- updateStage
  75. end
  76.  
  77. on init me
  78.   repeat with spritenum=1 to 48
  79.     if the membernum of sprite spritenum>0 then
  80.       set basecast=the membernum of sprite spritenum
  81.       set basecastname=the name of member basecast
  82.       if (char 1 to length(prefix) of basecastname)=prefix then
  83.         set btn=[:]
  84.         addprop btn,#basecast,basecast
  85.         addprop btn,#basecastname,basecastname
  86.         set locast=the number of member (basecastname&"1")
  87.         if locast<1 then
  88.           set locast=basecast
  89.           set hicast=basecast
  90.         else
  91.           repeat with index=1 to 100
  92.             if (the number of member (basecastname&index))<1 then
  93.               set hicast=the number of member (basecastname&(index-1))
  94.               set index=101
  95.             end if
  96.           end repeat
  97.         end if
  98.         addprop btn,#locast,locast
  99.         addprop btn,#hicast,hicast
  100.         addprop btn,#curcast,basecast
  101.         set downcast=the number of member (basecastname&"Down")
  102.         addprop btn,#downcast,downcast
  103.         addprop btnlist,spritenum,btn
  104.         set the membernum of sprite spritenum to basecast
  105.         puppetsprite spritenum,true
  106.         updateStage
  107.       end if
  108.     end if
  109.   end repeat
  110.   set lastbtn=0
  111.   set activesprite=0
  112.   set lastsprite=0
  113.   set lastframe=the frame
  114.   set downtime=0
  115.   set initflag=false
  116. end init
  117.  
  118. on reset me
  119.   repeat with spritepos=1 to count(btnlist)
  120.     set spritenum=getpropat(btnlist,spritepos)
  121.     set btn=getprop(btnlist,spritenum)
  122.     set the membernum of sprite spritenum to the basecast of btn
  123.     updateStage
  124.     puppetsprite spritenum,false
  125.   end repeat
  126.   set btnlist=[:]
  127.   set activesprite=0
  128.   set lastsprite=0
  129.   set downtime=the ticks
  130.   set pending=false
  131. end
  132.  
  133. on queryReset me
  134.   global gStatus
  135.   status gStatus
  136.   if the ticks-downtime>30 then
  137.     set initflag=true
  138.   end if
  139. end
  140.  
  141. on query me
  142.   global gStatus
  143.   if the frame<>lastframe then
  144.     set lastframe=the frame
  145.     reset me
  146.     exit
  147.   end if
  148.   set spritefound=false
  149.   if count(btnlist)=0 then
  150.     set downtime=the ticks
  151.     exit
  152.   end if
  153.   repeat with spritepos=1 to count(btnlist)
  154.     set spritenum=getpropat(btnlist,spritepos)
  155.     set btn=getprop(btnlist,spritenum)
  156.     if rollover(spritenum) then
  157.       set spritefound=true
  158.       if not (the mousedown) then
  159.         if pending=true then
  160.           reset me
  161.           set pending=false
  162.           exit
  163.         end if
  164.         if the curcast of btn=the basecast of btn then
  165.           set the curcast of btn to the locast of btn
  166.           trace me,spritenum
  167.         else
  168.           case btnmode of
  169.             #loop:
  170.               set the curcast of btn to the curcast of btn+1
  171.               if the curcast of btn>the hicast of btn then
  172.                 set the curcast of btn to the locast of btn
  173.               end if
  174.           end case
  175.         end if
  176.         set the membernum of sprite spritenum to the curcast of btn
  177.         status gStatus,the basecastname of btn
  178.       else
  179.         if the curcast of btn<>the downcast of btn then
  180.           if btnsound<>"" then
  181.             puppetSound btnsound
  182.           end if
  183.           set the curcast of btn to the downcast of btn
  184.           set the membernum of sprite spritenum to the curcast of btn
  185.           set pending=true
  186.         end if
  187.       end if
  188.     else
  189.       if the curcast of btn<>the basecast of btn then
  190.         set the curcast of btn=the basecast of btn
  191.         set the membernum of sprite spritenum to the curcast of btn
  192.         set lastbtn=spritenum
  193.       end if
  194.     end if
  195.   end repeat
  196.   if not spritefound then status gStatus
  197.   updateStage
  198. end
  199.  
  200.  
  201.  
  202. on dispose me
  203.   -- The following removes any old instances of the RolloverClass that
  204.   -- has the same prefix, then adds the current instance to the
  205.   -- actorlist.
  206.   repeat with index=1 to count(btnlist)
  207.     set spritenum=getpropat(btnlist,index)
  208.     set the membernum of sprite spritenum to the basecast of getprop(btnlist,spritenum)
  209.     updateStage
  210.     puppetsprite spritenum,false
  211.   end repeat
  212.   updateStage
  213.   set olddelimiter=the itemdelimiter
  214.   set the itemdelimiter=quote
  215.   repeat with obj in the actorlist
  216.     if (item 2 of string(obj))="RolloverClass" then
  217.       if the prefix of obj=prefix then
  218.         set pos=getpos(the actorlist,obj)
  219.         deleteat the actorlist,pos
  220.       end if
  221.     end if
  222.   end repeat
  223.   set the itemdelimiter=olddelimiter
  224. end
  225.  
  226. on trace me,spritenum
  227.   if lastbtn>0 then
  228.     puppetsound "LED0"&string(random(5))&".AIF",4
  229.     set tracesprite=castsprite("tracer")
  230.     set oldposH=the locH of sprite lastbtn
  231.     set oldposV=the locV of sprite lastbtn
  232.     set curposH=the locH of sprite spritenum
  233.     set curposV=the locV of sprite spritenum
  234.     set the visible of sprite tracesprite to true
  235.     puppetsprite tracesprite,true
  236.     set the locV of sprite tracesprite to oldposV
  237.     repeat with index=0 to 100
  238.       set the locH of sprite tracesprite to oldposH+(curposH-oldposH)*index/100
  239.       updateStage
  240.     end repeat
  241.     set the locH of sprite tracesprite to curposH
  242.     repeat with index=0 to 100
  243.       set the locv of sprite tracesprite to oldposv+(curposv-oldposv)*index/100
  244.       updateStage
  245.     end repeat
  246.     puppetsprite tracesprite,false
  247.     set the visible of sprite tracesprite to false
  248.   end if
  249. end
  250.  
  251.