home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 - Expo 2000 / Image.iso / t-online / show / xtras / animwiz.dir / 00009_Zooms.ls < prev    next >
Encoding:
Text File  |  1996-07-09  |  9.8 KB  |  266 lines

  1. property ioFieldList, iFieldFocus, ioFIeldFocus, iCurrentMotionStyleIndex, iCurrentVisualStyleIndex, ikMotionIn, ikMotionOut, ikMotionOutThenIn, ikMotionInThenOut, iFirstTime, iSaveSeconds, iSaveFPS, iSaveBaseline, iSaveDelayEnter, iSaveDelayHold, iSaveMark, iSaveCycles, iSaveSizeMin, iSaveSizeMax
  2.  
  3. on birth me
  4.   global goZoomsText, goSeconds, goFPS, goBaseline, goSizeMin, goSizeMax, goDelayEnter, goDelayHold, goCycles
  5.   set ioFieldList to [goZoomsText, goSeconds, goFPS, goSizeMin, goSizeMax, goBaseline, goDelayEnter, goDelayHold, goCycles]
  6.   set ikMotionIn to 1
  7.   set ikMotionOut to 2
  8.   set ikMotionOutThenIn to 3
  9.   set ikMotionInThenOut to 4
  10.   set iCurrentMotionStyleIndex to ikMotionIn
  11.   set iCurrentVisualStyleIndex to 1
  12.   set iFieldFocus to 1
  13.   set iFirstTime to 1
  14.   return me
  15. end
  16.  
  17. on mInit me
  18.   global goSeconds, goFPS, goBaseline, goSizeMin, goSizeMax, goDelayEnter, goDelayHold, goCycles, goZooms, goMarkFrame, goVisualStyles, goMotionStyles, goScoreMgr
  19.   mInit(goMarkFrame, 4)
  20.   if iFirstTime then
  21.     mSetValue(goSeconds, 5)
  22.     mSetValue(goFPS, 5)
  23.     set defaultBaseLine to integer(mGetStageHeight(goScoreMgr) / 2)
  24.     mSetValue(goBaseline, defaultBaseLine)
  25.     mSetValue(goSizeMin, 1)
  26.     mSetValue(goSizeMax, 100)
  27.     mSetValue(goDelayEnter, 0)
  28.     mSetValue(goDelayHold, 0)
  29.     mSetValue(goCycles, 1)
  30.     mSetValue(goMarkFrame, 1)
  31.     set iFirstTime to 0
  32.   else
  33.     mSetValue(goSeconds, iSaveSeconds)
  34.     mSetValue(goFPS, iSaveFPS)
  35.     mSetValue(goBaseline, iSaveBaseline)
  36.     mSetValue(goSizeMin, iSaveSizeMin)
  37.     mSetValue(goSizeMax, iSaveSizeMax)
  38.     mSetValue(goDelayEnter, iSaveDelayEnter)
  39.     mSetValue(goDelayHold, iSaveDelayHold)
  40.     mSetValue(goCycles, iSaveCycles)
  41.     mSetValue(goMarkFrame, iSaveMark)
  42.   end if
  43.   set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
  44.   set goMotionStyles to 0
  45.   set goMotionStyles to birth(script "RadioButton", 26, 4, 0, iCurrentMotionStyleIndex)
  46.   if the machineType < 256 then
  47.     mInit(goVisualStyles, the number of member "ZoomsVisualStylesMac", iCurrentVisualStyleIndex, 8, 19)
  48.   else
  49.     mInit(goVisualStyles, the number of member "ZoomsVisualStylesPC", iCurrentVisualStyleIndex, 8, 19)
  50.   end if
  51.   set the keyDownScript to "mCheckKey(goZooms)"
  52. end
  53.  
  54. on mSetFieldFocus me, oWhom
  55.   set where to getOne(ioFieldList, oWhom)
  56.   if where = 0 then
  57.     alert("Internal error - mSetFieldFocus could not find object")
  58.     return 
  59.   end if
  60.   set iFieldFocus to where
  61.   set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
  62. end
  63.  
  64. on mCheckKey me
  65.   if the key = TAB then
  66.     set iFieldFocus to IncrMod(iFieldFocus, count(ioFieldList))
  67.     set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
  68.     pass()
  69.   else
  70.     if iFieldFocus = 1 then
  71.       pass()
  72.     else
  73.       if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
  74.         pass()
  75.       else
  76.         dontPassEvent()
  77.       end if
  78.     end if
  79.   end if
  80. end
  81.  
  82. on mSetNewMotionStyle me, theNewStyleIndex
  83.   set iCurrentMotionStyleIndex to theNewStyleIndex
  84. end
  85.  
  86. on mSetNewVisualStyle me, theNewStyleIndex
  87.   set iCurrentVisualStyleIndex to theNewStyleIndex
  88. end
  89.  
  90. on mValidate me
  91.   global goSizeMin, goSizeMax
  92.   if mGetValue(goSizeMin) > mGetValue(goSizeMax) then
  93.     alert("The minimum size must be less than the maximum size.")
  94.     return 0
  95.   end if
  96.   set lastFieldOKFlag to mValidate(ioFIeldFocus)
  97.   return lastFieldOKFlag
  98. end
  99.  
  100. on mCreate me
  101.   global goMarkFrame, goMotionStyles, goVisualStyles, goScoreMgr, goCastMgr, gDevelopmentFlag, gCastNumTextAsBitmap, goPlatform
  102.   if not mValidate(me) then
  103.     return 
  104.   end if
  105.   if field "ZoomsText" = EMPTY then
  106.     alert("Please enter some text for the Zoom.")
  107.     return 
  108.   end if
  109.   tell the stage
  110.     set theStageFrame to the frame
  111.   end tell
  112.   set castNumVisualStyle to mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
  113.   set theVisualStyleName to the name of cast castNumVisualStyle
  114.   set theFont to word 2 of theVisualStyleName
  115.   set theSize to word 3 of theVisualStyleName
  116.   set theSeconds to integer(field "Seconds")
  117.   set fps to integer(field "FPS")
  118.   set baseLine to integer(field "BaseLine")
  119.   set delayEnter to integer(field "DelayEnter")
  120.   set delayHold to integer(field "DelayHold")
  121.   set nCycles to integer(field "Cycles")
  122.   set markFirst to mGetValue(goMarkFrame)
  123.   set sizeMin to integer(field "SizeMin")
  124.   set sizeMax to integer(field "SizeMax")
  125.   set nFrames to integer(theSeconds * fps)
  126.   if delayHold > 0 then
  127.     set nTotalFrames to (nFrames + 1) * nCycles
  128.   else
  129.     set nTotalFrames to nFrames * nCycles
  130.   end if
  131.   if not mInit(goScoreMgr, nTotalFrames, 1) then
  132.     return 
  133.   end if
  134.   set theCh to mGetNextSelectedChannel(goScoreMgr)
  135.   set theFrameNum to mGetStartFrame(goScoreMgr)
  136.   set castNumSource to mModifyRichTextCM(goCastMgr, the text of field "ZoomsText", theFont, theSize)
  137.   if castNumSource = 0 then
  138.     return 
  139.   end if
  140.   set the picture of member gCastNumTextAsBitmap to the picture of member castNumSource
  141.   set widthOfTextAsBitmap to float(the width of member gCastNumTextAsBitmap)
  142.   set heightOfTextAsBitmap to float(the height of member gCastNumTextAsBitmap)
  143.   set pctMin to float(sizeMin) / 100.0
  144.   set pctMax to float(sizeMax) / 100.0
  145.   set pctInc to (pctMax - pctMin) / float(nFrames - 1)
  146.   if (iCurrentMotionStyleIndex = ikMotionIn) or (iCurrentMotionStyleIndex = ikMotionOut) then
  147.     set nFrames1 to nFrames
  148.     set nFrames2 to 0
  149.   else
  150.     set nFrames1 to integer(nFrames / 2)
  151.     set nFrames2 to nFrames - nFrames1
  152.     set pctInc to pctInc * 2
  153.   end if
  154.   if (iCurrentMotionStyleIndex = ikMotionIn) or (iCurrentMotionStyleIndex = ikMotionInThenOut) then
  155.     set pctStart1 to pctMin
  156.     set pctInc1 to pctInc
  157.     set pctStart2 to pctMax
  158.     set pctInc2 to pctInc * -1.0
  159.   else
  160.     set pctStart1 to pctMax
  161.     set pctInc1 to pctInc * -1.0
  162.     set pctStart2 to pctMin
  163.     set pctInc2 to pctInc
  164.   end if
  165.   set theForeColor to 255
  166.   set theBackColor to 0
  167.   set castNumTarget to mFindFreeCastRun(goCastMgr, 1, 1)
  168.   copyToClipBoard(member gCastNumTextAsBitmap)
  169.   tell the stage
  170.     pasteClipBoardInto(member castNumTarget)
  171.     set the name of member castNumTarget to "BitMap" && string(the ticks)
  172.   end tell
  173.   set frameList to []
  174.   repeat with i = theFrameNum to theFrameNum + nTotalFrames - 1
  175.     add(frameList, [i])
  176.   end repeat
  177.   if markFirst then
  178.     set firstFrame to getAt(frameList, 1)
  179.     set theLabel to "AW.Zoom." & word 1 of the text of field "ZoomsText" & " " & mGetGeneratedScoreSelection(goScoreMgr)
  180.     add(firstFrame, [#label, theLabel])
  181.     setAt(frameList, 1, firstFrame)
  182.   end if
  183.   set relFrameCount to 1
  184.   repeat with thisCycle = 1 to nCycles
  185.     set xLoc to round(mGetStageWidth(goScoreMgr) / 2)
  186.     set yLoc to baseLine
  187.     set currentPct to pctStart1
  188.     set theWidth to currentPct * widthOfTextAsBitmap
  189.     set theHeight to currentPct * heightOfTextAsBitmap
  190.     set firstFrame to getAt(frameList, relFrameCount)
  191.     set secondFrame to getAt(frameList, relFrameCount + 1)
  192.     if delayEnter > 0 then
  193.       add(firstFrame, [#tempo, -delayEnter])
  194.       add(secondFrame, [#tempo, fps])
  195.     else
  196.       add(firstFrame, [#tempo, fps])
  197.       add(secondFrame, [#tempo, 0])
  198.     end if
  199.     setAt(frameList, relFrameCount, firstFrame)
  200.     setAt(frameList, relFrameCount + 1, secondFrame)
  201.     repeat with thisFrame = 1 to nFrames1
  202.       set theWidth to integer(theWidth + 0.49000000000000005)
  203.       set theHeight to integer(theHeight + 0.49000000000000005)
  204.       set currentFrame to getAt(frameList, relFrameCount)
  205.       add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight])
  206.       setAt(frameList, relFrameCount, currentFrame)
  207.       set theFrameNum to theFrameNum + 1
  208.       set currentPct to currentPct + pctInc1
  209.       set theWidth to currentPct * widthOfTextAsBitmap
  210.       set theHeight to currentPct * heightOfTextAsBitmap
  211.       set relFrameCount to relFrameCount + 1
  212.     end repeat
  213.     if delayHold > 0 then
  214.       set currentFrame to getAt(frameList, relFrameCount)
  215.       add(currentFrame, [#tempo, -delayHold])
  216.       set theWidth to integer(theWidth + 0.49000000000000005)
  217.       set theHeight to integer(theHeight + 0.49000000000000005)
  218.       add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight])
  219.       setAt(frameList, relFrameCount, currentFrame)
  220.       set theFrameNum to theFrameNum + 1
  221.       set relFrameCount to relFrameCount + 1
  222.     end if
  223.     if nFrames2 > 0 then
  224.       set currentPct to pctStart2
  225.       set theWidth to currentPct * widthOfTextAsBitmap
  226.       set theHeight to currentPct * heightOfTextAsBitmap
  227.       repeat with thisFrame = 1 to nFrames2
  228.         set theWidth to integer(theWidth + 0.49000000000000005)
  229.         set theHeight to integer(theHeight + 0.49000000000000005)
  230.         set currentFrame to getAt(frameList, relFrameCount)
  231.         add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight])
  232.         setAt(frameList, relFrameCount, currentFrame)
  233.         set theFrameNum to theFrameNum + 1
  234.         set currentPct to currentPct + pctInc2
  235.         set theWidth to currentPct * widthOfTextAsBitmap
  236.         set theHeight to currentPct * heightOfTextAsBitmap
  237.         set relFrameCount to relFrameCount + 1
  238.       end repeat
  239.     end if
  240.   end repeat
  241.   mWriteFrame(goScoreMgr, frameList)
  242.   set labelName to "Zooms" & goPlatform
  243.   go(label(labelName) + 2)
  244.   if not gDevelopmentFlag then
  245.     tell the stage
  246.       go(theStageFrame)
  247.     end tell
  248.   end if
  249.   mClean(goScoreMgr)
  250. end
  251.  
  252. on mCleanUp me
  253.   global goMotionStyles, goSeconds, goFPS, goBaseline, goSizeMin, goSizeMax, goDelayEnter, goDelayHold, goCycles, goMarkFrame
  254.   mCleanUp(goMotionStyles)
  255.   set iSaveSeconds to mGetValue(goSeconds)
  256.   set iSaveFPS to mGetValue(goFPS)
  257.   set iSaveBaseline to mGetValue(goBaseline)
  258.   set iSaveSizeMin to mGetValue(goSizeMin)
  259.   set iSaveSizeMax to mGetValue(goSizeMax)
  260.   set iSaveDelayEnter to mGetValue(goDelayEnter)
  261.   set iSaveDelayHold to mGetValue(goDelayHold)
  262.   set iSaveCycles to mGetValue(goCycles)
  263.   set iSaveMark to mGetValue(goMarkFrame)
  264.   mCleanUp(goMarkFrame)
  265. end
  266.