home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////
- //
- // ADOBE SYSTEMS INCORPORATED
- // Copyright 2002 Adobe Systems Incorporated
- // All Rights Reserved
- //
- // NOTICE: Adobe permits you to use, modify, and
- // distribute this file in accordance with the terms
- // of the Adobe license agreement accompanying it.
- // If you have received this file from a source
- // other than Adobe, then your use, modification,
- // or distribution of it requires the prior
- // written permission of Adobe.
- //
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // Rotate and Size.js
- //
- // DESCRIPTION
- //
- // This script demonstrates the use of stopwatches with timeline.
- // Switch to Preview mode to watch the object rotate
- // and change size at the same time.
- //
- // HOW TO USE
- //
- // Create any object and select it in the Composition.
- // Select Automation > Run Automation Script > Rotate And Size.js
- // Click on Preview Mode to view the object resize and rotate.
- //
- //////////////////////////////////////////////////
-
- // Main Code [Execution of script begins from here]
- // Check if any composition is open
- if(application.compositions.length > 0){
- comp = application.currentComposition;
- if(comp.selection.length >= 1){ // Checks if at least one object is selected
- targets = comp.selection;// Assigns the current selection to targets
-
- application.currentComposition.saveSelection(); // saves the current selection
-
- // Call function rotateAndSize
- rotateAndSize(targets, 24, 3, 2, 300, 225, 10);
- // Make changes in the parameters here to change the behavior of this function.
-
- application.currentComposition.restoreSelection(); // restores the saved selection
- }
- else{ // If no objects are selected brings the Console window up
- Console.show();
- // Writes to the Console
- Console.write("Please select the objects to apply the Animation and run the script again.\n");
- }
- }
- else{// if no composition open
- // opens a new composition
- comp = application.newComposition();
- Console.show();
- Console.write("New Composition opened\nPlease create and select the objects to apply the Animation and run the script again.\n");
- }
-
-
- // Add your own functions here
-
- //////////////////////////////////////////////////
- // rotateAndSize:
- // Changes the size and rotates the targets objects
- //
- // targets: The objects to rotate and change size of
- // frames: Total number of frames
- // KFR: [KeyFrameRate] Rate at which to place key frames
- // stagger: The delay between frames
- // rotation: The angle of rotation
- // scale: The end X and Y position of the object
- // size: The final size of object
- //////////////////////////////////////////////////
-
- function rotateAndSize(targets, frames, KFR, stagger, rotation, scale, size)
- {
- var oriPosX; //Original X position
- var oriPosY; //Original Y position
- var oriSizeX; //Original X size - width
- var oriSizeY; //Original Y size - height
- var oriAngle; //Original angle of rotation
- var frame0 = targets[0].currentFrame; // First object is current frame
-
- for(var i=0 ; i < targets.length ; i++){
- // Store original values before starting stopwatch
- oriPosX = targets[i].position.x;
- oriPosY = targets[i].position.y;
- oriSizeX = targets[i].size.x;
- oriSizeY = targets[i].size.y;
- oriAngle = targets[i].rotation;
-
- // Check and start the stopwatches for rotation, size and position
- if(rotation != oriAngle)
- targets[i].stopwatch.rotation = true;
- if(size != 200)
- targets[i].stopwatch.size = true;
- if(scale != targets[i].position.x || scale != targets[i].position.y)
- targets[i].stopwatch.position = true;
-
-
- // Note: The initial positions are not stored by turning on the stopwatch.
- // The stopwatch only records changes AFTER it's been turned on.
-
-
- targets[0].currentFrame = frame0 + ( i * stagger );
- targets[i].rotation = oriAngle;
- targets[i].position.x = oriPosX;
- targets[i].position.y = oriPosY;
- targets[i].size.x = oriSizeX;
- targets[i].size.y = oriSizeY;
-
- // final frame
- targets[i].currentFrame = frame0 + frames + (i * stagger);
- targets[i].rotation = rotation;
- targets[i].position.x = scale ;
- targets[i].position.y = scale;
- targets[i].size.x = size;
- targets[i].size.y = size;
- }
- }
-
-