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.
- //
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // Fast Character Animation.js
- //
- // DESCRIPTION
- //
- // This script takes the selected text object and breaks it
- // into individual character objects and animates the appearance
- // of characters in a sequence. It also changes background to a single
- // color and the text color to a single color.
- //
- // HOW TO USE
- //
- // Create any Text object and select it in the Composition.
- // Select Automation > Run Automation Script > Fast Character Animation.js
- //
- // You can view the animation in Preview or Export the file
- // and view the html in the browser.
- //
- //////////////////////////////////////////////////
-
- // 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
- var selected = comp.selection; // Currently selected objects
- var objects = new Array(); // An array to store individual characters
- // Breaks the text object into individual characters and assign to the array objects.
- objects = selected[0].convertIntoObjects();
- application.currentComposition.saveSelection(); // Saves the current selection
-
- animate(objects, 3, 20, 100);// Call function animate to animate the characters
- // You can make changes in the parameters here to call function with different
- // values
-
- application.currentComposition.restoreSelection(); // Restores the saved selection
- }
- else{ // Brings up the console window
- Console.show();
- // Writes the requirement to the console
- Console.write("\nPlease create and select at least one text object to apply charater 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 at least one text object to apply charater animation and run the script again.\n");
- }
-
- // Setting the start color of the background color sets background to a single color
- // Setting color to black here so r=0, g=0 and b=0;
- comp.backgroundColorGradient.startColor.red = 0;
- comp.backgroundColorGradient.startColor.green = 0;
- comp.backgroundColorGradient.startColor.blue = 0;
-
-
-
- // Add your own functions here
-
- //////////////////////////////////////////////////
- //
- // animate:
- // Animates the appearance of the individual character
- // objects.
- //
- // Each object is kept invisible for a limited amout
- // of time/frames. Object 1 is invisible for first 3
- // frames, object 2 is invisible for first 6 frames
- // and so on...And then they all appear gradually.
- //
- // object_Array: The array of characters to be animated
- // keyFrameRate: The frame at which the opacity of the
- // object changes.
- // incrementValue: The amount of opacity increased gradually.
- // finalOpacity: The final maximum opacity to be given to
- // the object.
- //
- //////////////////////////////////////////////////
-
- function animate(object_Array, keyFrameRate, incrementValue, finalOpacity){
- var oriOpacity=0; // Variable to store original/start opacity of the object
- var frame0; // Variable to store start frame of each object
- var f; // Variable for the frame number
- var end; // Variable for end of invisibility of characters
- var objOpacity; // Variable to store opacity of object for comparison
-
- // Loop to make all objects invisible and change their color to green
- for(i=0 ; i < object_Array.length ; i++){
-
- // Setting objects start color to a single color - green.
- object_Array[i].layers[0].colorGradient.startColor.red = 31;
- object_Array[i].layers[0].colorGradient.startColor.green = 255;
- object_Array[i].layers[0].colorGradient.startColor.blue = 60;
-
- // To make all characters invisible changing their opacity to 0.
- object_Array[i].opacity = 0;
- }
-
- // Loop to stagger appearance of all objects first and then make them
- // visible gradually
- for(i=0 ; i < object_Array.length ; i++){
-
- // Start all objects animation at the same frame/time
- frame0 = object_Array[i].startFrame;
-
- // Start the stopwatch for opacity
- object_Array[i].stopwatch.opacity = true;
-
- // Since starting does not record the attribute assign it again
- // to record it's value
- object_Array[i].opacity = oriOpacity ;
-
- // Objects are invisible for end frames i.e. 3 for object 1,
- // 6 for object 2 and so on respectively
- // The formula used to caluclate end time is:
- // (i+1) * keyFrameRate = 1*3 = 3 for object i (object 1)
- // (i+1) * keyFrameRate = 2*3 = 6 for object i (object 2)
- end = (i+1)*keyFrameRate;
-
- // Assigning current opacity of object to objOpacity for
- // comparison
- objOpacity = object_Array[i].opacity;
-
- // Loop to set opacity 0 through frames for each object's
- // invisibility time.
- // Gradually increase their opacity to complete visibility
- // Begin with the first frame 0
- for( f=0 ; objOpacity < finalOpacity; f+=keyFrameRate){
- // Set the key frame at the current frame
- object_Array[i].currentFrame = frame0 + f;
-
- // Check the frame number and keep it invisible/visible
- if(f <= end){
- object_Array[i].opacity = 0;
- }
- else{
- object_Array[i].opacity = objOpacity + incrementValue;
- }
-
- // Assign opacity to objOpacity for comparison
- objOpacity = object_Array[i].opacity;
- }
- }
- }
-