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.
- ***************************************************************/
- /***************************************************************
- Author: Mary Obelnicki
- ***************************************************************/
-
- /***************************************************************
- alignEndToEnd is a utility that allow the user to align the lifetimes
- of a selection of objects.
-
- When aligning the lifetimes there are a number of options. The user can
- control if the key frames are moved with the lifetimes or left in place,
- if the first lifetime is aligned to the CTI, if the original start order
- of the lifetimes is maintained in the stagger, if the original order is
- not maintained, if the objects should be staggered from top down, or
- bottom up, the amount of overlap between the lifetimes and the type of
- transition between the lifetimes.
-
- alignEndToEnd(arrayObjs, moveKeyFrames, alignToCTI, maintainStartOrder, topDown, overlap, transition);
-
- Arguments:
- arrayObjs (array) - the array of LMObjects to align the lifetimes of
- moveKeyFrames (boolean) - True: move the key frames with the lifetime.
- False: the key frames in place.
- alignToCTI (boolean) - True: place the first object's lifetime at the current
- position of the CTI. False: the start frame of the first object will be set to 0.
- maintainStartOrder (boolean) - True: maintain the order of start key frames.
- False: the start order will be automatically sorted as determined by topDown.
- topDown (boolean) - True: the order of sorting will be dependent upon the LMObject's
- z-order. The object at the top will start first. False: start order will
- be from the bottom up.
- overlap (integer) - number of frames of overlap between lifetimes
- transition (integer) - transition style in frames of overlap
- 0: no style
- 1: fade in
- 2: fade out
- 3: fade in and out
-
- Example:
- alignEndToEnd(application.currentComposition.selection,true,false,false,true,3,2);
-
- ***************************************************************/
-
-
- /***************************************************************
- DO NOT EDIT BELOW THIS LINE
- ***************************************************************/
-
- #include "shellSort.js"
-
- function alignEndToEnd(theObjects, moveKeyFrames, alignToCTI, maintainStartOrder, topDown, overlap, transitionStyle)
- {
- //turn all lifetimes explicit otherwise this function doesn't
- //really make sense
- var i;
- for(i = 0; i<theObjects.length; i++)
- theObjects[i].explicitLifetime = true;
-
- if(maintainStartOrder)
- shellSort(theObjects, "startFrame");
- else if(!topDown)
- theObjects.reverse();
-
- if(alignToCTI)
- {
- var cti = theObjects[0].currentFrame;
-
- if(moveKeyFrames)
- theObjects[0].moveLifetimeTo(cti);
- else
- {
- var lifetimeLength = theObjects[0].endFrame - theObjects[0].startFrame;
- theObjects[0].startFrame = cti;
- theObjects[0].endFrame = cti + lifetimeLength;
- }
- }
-
- //align the lifetimes
- for(i = 1; i<theObjects.length; i++)
- {
- var curO = theObjects[i];
- var prevO = theObjects[i-1];
- var actualOverlap = Math.min(overlap, (curO.endFrame - curO.startFrame + 1) );
- if(moveKeyFrames)
- {
- curO.moveLifetimeTo(Math.max((prevO.endFrame + 1 - actualOverlap), prevO.startFrame) );
- }
- else
- {
- var lifetimeLength = curO.endFrame - curO.startFrame;
- curO.startFrame = Math.max((prevO.endFrame + 1 - actualOverlap), prevO.startFrame);
- curO.endFrame = curO.startFrame + lifetimeLength;
- }
- }
-
- if(overlap > 0)
- {
- for (i = 0; i<theObjects.length; i++)
- {
- applyTransition(transitionStyle, overlap, theObjects[i]);
- }
- }
- }
-
- function applyTransition(style, frames, theObj)
- {
- var lifetimeFrames = theObj.endFrame - theObj.startFrame + 1;
- var offset;
- if(style == 3)
- offset = Math.min(frames, Math.ceil(lifetimeFrames/2)) - 1;
- else
- offset = Math.min(frames, lifetimeFrames) - 1;
-
- theObj.currentFrame = theObj.startFrame;
- var oriOpacity = theObj.opacity;
-
- if((style == 1) || (style == 3)) // fade in
- {
- theObj.stopwatch.opacity = true;
- theObj.currentFrame = theObj.startFrame + offset;
- theObj.opacity = oriOpacity * offset/(frames-1);
- theObj.currentFrame = theObj.startFrame;
- theObj.opacity = 0;
- }
- if((style == 2) || (style == 3)) // fade out
- {
- theObj.stopwatch.opacity = true;
- theObj.currentFrame = theObj.endFrame - offset;
- theObj.opacity = oriOpacity * offset/(frames-1);
- theObj.currentFrame = theObj.endFrame;
- theObj.opacity = 0;
-
- }
- }
-