home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Automation / Scripts / Draggable Object Maker.js < prev    next >
Encoding:
Text File  |  2002-05-13  |  2.2 KB  |  66 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2002 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Henry Lee
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17.  
  18. This script is executed on the current selection. The script 
  19. makes the objects in the selection all capable of supporting
  20. "drag-and-drop" in preview and export. The script will set the 
  21. movie clip flag to true and add in two lines of code to the 
  22. selected objects. 
  23.  
  24. onButtonPress:
  25.   this.startDrag();
  26.   
  27. onButtonRelease:
  28.   this.stopDrag();
  29.  
  30. ***************************************************************/
  31.  
  32. /***************************************************************
  33. To change the behavior of this script, make your changes below
  34. ***************************************************************/
  35.  
  36. comp = application.currentComposition;
  37. objs = comp.selection;
  38.  
  39. makeDraggable(objs);
  40.  
  41. /***************************************************************
  42. DO NOT EDIT BELOW THIS LINE
  43. ***************************************************************/
  44.  
  45.  
  46. function makeDraggable(targets) {
  47.   var startScript;
  48.   var stopScript;
  49.  
  50.   for (var i=0; i<targets.length; i++) {
  51.     targets[i].isMovieClip = true;
  52.     if (targets[i].states.length < 1) {
  53.       targets[i].addState();
  54.     }
  55.     
  56.     startScript = targets[i].getHandlerScript(LMHandlerType.onButtonPress);
  57.     startScript += "\nthis.startDrag();\n";
  58.     stopScript =  targets[i].getHandlerScript(LMHandlerType.onButtonRelease);
  59.     stopScript += "\nthis.stopDrag();\n";
  60.  
  61.     targets[i].setHandlerScript(LMHandlerType.onButtonPress, startScript);
  62.     targets[i].setHandlerScript(LMHandlerType.onButtonRelease, stopScript);
  63.   }
  64. }
  65.  
  66.