MaskMoveFX Documentation
Author: Alex Uhlmann, Ben Jackson
Last Modified: 09/24/05 19:04:39
Summary
MaskMoveFX class:
MaskMoveFX Properties:
MaskMoveFX Methods:
version: Documentation not provided.
description:
a mask using move effects. You can specify the duration, easing equation and callback properties either with setting the properies directly or with the animationStyle() method like it is used in de.alex_uhlmann.animationpackage.drawing. You can also send the animationStyle properties via the run() method or via the constructor. See the following examples. The move effect needs to be specified as a string abbreviation. Available mask move effects are:
"L" = left, moves the mask to the left. "R" = right, moves the mask to the right. "T" = top, moves the mask to the top. "B" = bottom, moves the mask to the bottom. "TL" = top left, moves the mask to the top left corner. "TR" = top right, moves the mask to the top right corner. "BL" = bottom left, moves the mask to the bottom left corner. "BR" = bottom right, moves the mask to the bottom right corner. "CUSTOM" = moves the mask according to the adjustmentObj parameter.
Example 1: (Example .swf) Draw a rectangle and use it as a mask over movieclip mc.
var myRect:Rectangle = new Rectangle(50,50,100,50);
myRect.draw();
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc,myRect.movieclip);
myMaskMoveFX.animationStyle(2000,Circ.easeInOut);
myMaskMoveFX.run("L",0,100);
If you don't specify a mask movieclip,
a Rectangle will be created in the parent timeline of mc.
You can alter a predefined move effect or you can define a custom move effect via the adjustmentObj. The adjustmentObj of MaskMoveFX is an Object that contains five optional properties.
scaleOffset = Specifies the scaling of the mask. Defaults to 120 or 160, depening on the specified move effect. If null is specified, the mask movieclip won't be scaled at all. startX = Start point to move the mask from. Coordinate point x. startY = Start point to move the mask from. Coordinate point y. endX = End point to move the mask to. Coordinate point x. endY = End point to move the mask to. Coordinate point y.
Example 2: (Example .swf) Mask only a specific part in the masked movieclip. Move according to the adjustmentObj. Note that you can prevent automatic scaling of your mask movieclip if you set scaleOffset to null.
var myRect:Rectangle = new Rectangle(50,50,158,25);
myRect.draw();
var mcBounds:Object = mc.getBounds(_root);
var myMaskMoveFX1:MaskMoveFX = new MaskMoveFX(mc,myRect.movieclip);
AnimationCore.duration_def = 2000;
AnimationCore.easing_def = Circ.easeInOut;
myMaskMoveFX1.run("CUSTOM",0,100,{
scaleOffset:null,
startX:mcBounds.xMin,
startY:mcBounds.yMax-22,
endX:mcBounds.xMax-92,
endY:mcBounds.yMax-22
});
Note that the start and end values (0 and 100) in example 2 have no effect when using the CUSTOM move effect. Furthermore, note that you can also alter predefined move effects via the properties of the adjustmentObj. You don't have to specify the CUSTOM move effect, when you want to customize a move effect.
Note that all examples above created a mask movieclip above the masked mc. If you want to manipulate physical movieclip properties of the masked movieclip, and at the same time animate the movieclip with a mask effect, the mask effect would be disturbed. Here is a solution:
Example 3: (Example .swf) Using the Parallel class we use a mask effect and manipulate many physical properties of movieclip "mc" at the same time.
var myMoveOnQuadCurve:MoveOnQuadCurve = new MoveOnQuadCurve(mc,100,100,300,300,500,100); var myScale:Scale = new Scale(mc,50,50); var myColorTransform:ColorTransform = new ColorTransform(mc,0xff0000,50); //create the mask movieclip inside the movieclip mc to reflect all manipulations to mc. var mask_mc:MovieClip = mc.createEmptyMovieClip("mask_mc",1); var myRect:Rectangle = new Rectangle(mask_mc,50,50,100,50); myRect.draw(); //since the mask is inside mc you have to mask a movieclip inside mc. var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc.inner_mc,myRect.movieclip,"TL"); var myParallel:Parallel = new Parallel(); myParallel.addChild(myMoveOnQuadCurve); myParallel.addChild(myScale); myParallel.addChild(myColorTransform); myParallel.addChild(myMaskMoveFX); myParallel.animationStyle(2000,Circ.easeInOut,"onCallback"); myParallel.animate(0,100); myListener.onCallback = function(source) { source.callback = "onCallback2"; source.animate(100,0); } myListener.onCallback2 = function(source) { source.callback = "onCallback"; source.animate(0,100); }
usage:
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect, duration);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect, duration, callback);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect, duration, easing, callback);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect, adjustmentObj);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect, adjustmentObj, duration);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect, adjustmentObj, duration, callback);
var myMaskMoveFX:MaskMoveFX = new MaskMoveFX(mc, mask_mc, effect, adjustmentObj, duration, easing, callback);
parameters:
(MovieClip) Movieclip to be masked.
(MovieClip) Movieclip to use as a mask.
(Number) Duration of animation in milliseconds or frames. Default is milliseconds.
(Object) Easing equation in Robert Penner style. Default equation is Linear.easeNone. www.robertpenner.com/easing/
(String) Function to invoke after animation. See AnimationCore class.
description: Animates a mask using move effects from and to a specified amount in a specified time and easing equation. See class description for details.
usage:
myMaskMoveFX.run(effect, start, end);
myMaskMoveFX.run(effect, start, end, duration);
myMaskMoveFX.run(effect, start, end, duration, callback);
myMaskMoveFX.run(effect, start, end, duration, easing, callback);
myMaskMoveFX.run(effect, start, end, adjustmentObj);
myMaskMoveFX.run(effect, start, end, adjustmentObj, duration);
myMaskMoveFX.run(effect, start, end, adjustmentObj, duration, callback);
myMaskMoveFX.run(effect, start, end, adjustmentObj, duration, easing, callback);
parameters:
returns: void
description: similar to the run() method. Offers start and end parameters.
usage:
myMaskMoveFX.animate(start, end);
parameters:
returns: void
description: jumps to a specific step of the animation and stays there.
usage:
instance.goto(percentage);
parameters:
returns: void
description: set the animation style properties for your animation. Notice that if your easing equation supports additional parameters you can send those parameters with the easing parameter in animationStyle. You have to send an Array as easing parameter. The first element has to be the easing equation in Robert Penner style. The following parameters can be your additional parameters. i.e.:
See also "Customizable easing equations" in readme for more information.var myRotation:Rotation = new Rotation(mc); myRotation.animationStyle(2000,[Back.easeOut,4]); myRotation.run(360);
usage:
myInstance.animationStyle(duration);
myInstance.animationStyle(duration, callback);
myInstance.animationStyle(duration, easing, callback);
parameters:
returns: Void.
description: Flash does not guaranteed that time-based tweening will reach the end value(s) of your animation. By default AnimationPackage guarantees that the end value(s) will be reached. The forceEnd method allows you to disable this guarantee and only accept the values from your easing equation. In certain situations this can lead to a smoother ending of the animation. Notice that in frame-based tweening the end value(s) will always be reached.
usage:
myInstance.forceEnd(forceEndVal);
parameters:
true or false.returns: Void.
description: returns the optimization mode. See setOptimizationMode for more information.
usage: getOptimizationMode();
returns: Boolean
description:
Allows to explicitly remove parts of the animation that don't change during
the animation.
This can add additional performance to your animation. Note that
setting this method to true has side effects. If all start and end values match,
the animation won't start and will immediatly invoke an onEnd event.
The order of values returned by getStartValue(s), getCurrentValue(s),
getEndValue(s) and the value property of the eventObject returned
by EventDispatcher might change if you set this method to true. You can
still retrieve the parts of the animation that are actually animated
if you access the Animator instance of your animation class via
myAnimator. Ask myInstance.myAnimator.setter to retrieve
all currently animated parts of the animation. See Animator
documentation. Of cource, if you know your input values you would
probably look at them.
Note that the AnimationCore class offers a static setOptimizationModes method (note the last "s" at the end) that allows you to remove parts of 'all' your animations that don't change during the animation.
usage:
myInstance.setOptimizationMode(optimize);
parameters:
returns: Void.
description: returns the current tween mode used by the instance. Please check with AnimationCore.setTweenModes for more information.
usage: getTweenMode();
returns: String that specifies the tween mode. Either AnimationCore.INTERVAL or AnimationCore.FRAMES.
description: sets the current tween mode used by the instance. Please check with AnimationCore.setTweenModes for more information.
usage: setTweenMode();
parameters:
returns: true if setting tween mode was successful,
false if not successful.
description: returns the current duration mode used by the instance. Please check with AnimationCore.setTweenModes for more information.
usage: getDurationMode();
returns: String that specifies the duration mode. Either AnimationCore.MS or AnimationCore.FRAMES.
description: sets the current duration mode used by the instance. Please check with AnimationCore.setTweenModes for more information.
usage: setDurationMode();
parameters:
returns: true if setting duration mode was successful,
false if not successful.
description: stops the animation if not locked..
usage: myInstance.stop();
returns: true if instance was successfully stopped.
false if instance could not be stopped, because it was locked.
description: pauses the animation if not locked. Call resume() to continue animation.
usage: myInstance.pause();
parameters:
returns: true if instance was successfully paused.
false if instance could not be paused, because it was locked.
description: continues the animation if not locked.
usage: myInstance.resume();
returns: true if instance was successfully resumed.
false if instance could not be resumed, because it was locked.
description: locks the animation to prevent pausing, resuming and stopping. Default is unlocked.
usage: myInstance.lock();
returns: Void.
description: unlocks the animation to allow pausing, resuming and stopping. Default is unlocked.
usage: myInstance.unlock();
returns: Void.
description: checks if the instance is currently animated.
usage: myInstance.isTweening();
returns: true if instance is tweening,
false if instance is not tweening.
description: returns the original, starting values of the current tween. _x and _y properties.
usage: myInstance.getStartValues();
returns: (Array) First value is _x, second is _y.
description: returns the targeted values of the current tween. _x and _y properties.
usage: myInstance.getEndValues();
returns: (Array) First value is _x, second is _y.
description: returns the current values of the current tween. _x and _y properties.
usage: myInstance.getCurrentValues();
returns: (Array) First value is _x, second is _y.
description: returns the current state of the animation in percentage. Especially usefull in combination with goto().
usage: myInstance.getCurrentPercentage();
returns: Number
description: returns the elapsed time or frames since the current tween started tweening.
usage: myInstance.getDurationElapsed();
returns: Number
description: returns the remaining time or frames since the current tween started tweening.
usage: myInstance.getDurationRemaining();
returns: Number
description: Subscribe to a predefined event. The following standard EventDispatcher events are broadcasted
onStart, broadcasted when animation starts.
onUpdate, broadcasted when animation updates.
onEnd, broadcasted when animation ends.
The even object returned, contains the following properties:
type (String) event broadcasted.
target (Object) event source.
usage:
myMaskMoveFX.addEventListener(event, listener);
myMaskMoveFX.addEventListener(event, listener, handler);
parameters:
returns: Void.
description: Removes a listener from a subscribed event.
usage:
myMaskMoveFX.removeEventListener(event, listener);
myMaskMoveFX.removeEventListener(event, listener, handler);
parameters:
returns: Void.
description: GDispatcher specific feature. Removes all listeners for a specific event, or for all events.
usage:
myMaskMoveFX.removeAllEventListeners();
myMaskMoveFX.removeAllEventListeners(event);
parameters:
returns: Void.
description: GDispatcher specific feature. Checks if a listener is already subscribed to a certain event.
usage:
myMaskMoveFX.eventListenerExists(event, listener);
myMaskMoveFX.eventListenerExists(event, listener, handler);
parameters:
returns: true if event exists on listener.
false if event doesn't exist on listener.
description: returns a unique ID of the instance. Usefull for associative arrays.
usage: myInstance.getID();
returns: Number
description: returns the name of the class.
usage: myInstance.toString();
returns: String