home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / ch06_med / txtchngr / txtchngr.dcr / 00002.ls < prev    next >
Encoding:
Text File  |  1996-12-06  |  2.9 KB  |  92 lines

  1. on setStyles
  2.   global fontNameList, fontSizeList, fontStyleList
  3.   if the machineType = 256 then
  4.     set fontNameList to ["times new roman", "arial", "helvetica", "new courier"]
  5.   else
  6.     set fontNameList to ["times", "geneva", "chicago", "monaco"]
  7.   end if
  8.   set fontSizeList to [9, 10, 12, 14, 18, 24]
  9.   set fontStyleList to ["plain", "italic", "underline", "condense"]
  10.   set showMe to 0
  11.   initColorLists()
  12. end
  13.  
  14. on initColorLists
  15.   global gray2black, black2gray, useMeColors
  16.   set black2gray to [255, 254, 253, 252, 251]
  17.   set gray2black to [251, 252, 253, 254, 255]
  18.   set useMeColors to [251, 252, 253, 254, 255, 244, 243, 242, 241, 234, 224, 219, 220, 212, 213, 214, 208, 207, 206, 202, 200, 12, 27, 44, 46, 48, 50, 51, 52, 106, 107]
  19. end
  20.  
  21. on stopMovie
  22. end
  23.  
  24. on enterFrame
  25.   global showMe
  26.   if showMe then
  27.     randomOperate()
  28.   end if
  29. end
  30.  
  31. on initHeightPatch
  32.   global gRealTHList
  33.   set gRealTHList to [:]
  34.   repeat with i = 30 to 34
  35.     set thisOne to the name of cast i
  36.     setaProp(gRealTHList, "#" & thisOne, 0)
  37.   end repeat
  38. end
  39.  
  40. on randomOperate
  41.   global gRealTHList, gray2black, black2gray, useMeColors, fontNameList, fontSizeList, fontStyleList, gExitOp
  42.   set theFieldNum to random(count(gRealTHList))
  43.   set N to 1
  44.   set theField to "text" & theFieldNum
  45.   set chunkType to "word"
  46.   do("set " & "n" & " = the number of " & chunkType & "s in field " & QUOTE & theField & QUOTE)
  47.   set N to random(N)
  48.   set infoLine to N && "of field" && QUOTE & theField & QUOTE
  49.   set exitOp to "if the textStyle of" && chunkType && infoLine & gExitOp
  50.   put exitOp
  51.   put N
  52.   set opType to random(4)
  53.   set opsList to ["size", "color", "font", "style"]
  54.   if opType = 1 then
  55.     changeTextSize(theField, chunkType && N, getAt(fontSizeList, random(count(fontSizeList))))
  56.   else
  57.     if opType = 2 then
  58.       changeTextColor(theField, chunkType && N, getAt(useMeColors, random(count(useMeColors))))
  59.     else
  60.       if opType = 3 then
  61.         changeTextFont(theField, chunkType && N, getAt(fontSizeList, random(count(fontNameList))))
  62.       else
  63.         if opType = 4 then
  64.           changeTextStyle(theField, chunkType && N, getAt(fontStyleList, random(count(fontStyleList))))
  65.         end if
  66.       end if
  67.     end if
  68.   end if
  69. end
  70.  
  71. on resetAllFields
  72.   global fontNameList, fontStyleList, gFields, showMe
  73.   repeat with i = 1 to 5
  74.     set theField to getAt(gFields, i)
  75.     set highChar to the number of words in field theField
  76.     changeTextSize(theField, "word 1 to " & highChar, 12)
  77.     if showMe then
  78.       morphHeight(theField, 1)
  79.     end if
  80.     changeTextColor(theField, "word 1 to " & highChar, 255)
  81.     changeTextStyle(theField, "word 1 to " & highChar, getAt(fontStyleList, 1))
  82.     changeTextFont(theField, "word 1 to " & highChar, getAt(fontNameList, 1))
  83.     repeat with j = 1 to the number of lines in field theField
  84.       if line j of field theField contains "?" then
  85.         changeTextStyle(theField, "line " & j, "bold")
  86.       end if
  87.     end repeat
  88.     morphHeight(theField, 24)
  89.   end repeat
  90.   updateStage()
  91. end
  92.