DropShadow Documentation
Author: Alex Uhlmann
Last Modified: 09/28/05 09:59:19
Summary
DropShadow class:
DropShadow Properties:
DropShadow Methods:
version: Documentation not provided.
description:
Animates the DropShadowFilter of a movieclip or a number of movieclips.
Example 1: (Example .swf) apply a filter animation with default values.
import flash.filters.DropShadowFilter; var filterEnd:DropShadowFilter = new DropShadowFilter(); new DropShadow(mc,filterEnd).animate(0,100);
Example 2: (Example .swf) do the same, just the other way around
import flash.filters.DropShadowFilter; var filterEnd:DropShadowFilter = new DropShadowFilter(); new DropShadow(mc,filterEnd).animate(100,0);
Example 3: (Example .swf) As with other IAnimatable classes you can set specific start and end values. To do the same as in example 2 you can apply a default filter instance as start value and a "null" value as end value. null defines a filter instance that won't be visible.
import flash.filters.DropShadowFilter; var filterStart:DropShadowFilter = new DropShadowFilter(); var myDropShadow:DropShadow = new DropShadow(mc,[filterStart,null]); myDropShadow.animationStyle(1000,Linear.easeNone); myDropShadow.animate(0,100);
Example 4: (Example .swf) Instances of the flash.filters classes are stacked to the filters Array of the movieclip you use. AnimationPackage offers you control if you want to animate existing filters, if you want to create a new filter, or replace an existing filter. By default, and in the examples above, we've always added a new filter instance to our movieclip mc. If you want to animate an existing filter you have to specify the index of the element in the movieclip's filters Array you want to manipulate. This example applies two different filters to the filters Array of movieclip mc and then animates element 1, which is the DropShadowFilter. You would replace the GlowFilter at index 0 and add new filter with specifying either no filterIndex as in the examples above or an index higher than 1.
import flash.filters.GlowFilter;
import flash.filters.DropShadowFilter;
var glowFilter:GlowFilter = new GlowFilter();
mc.filters = [glowFilter];
var dropShadowFilter:DropShadowFilter = new DropShadowFilter();
mc.filters = [glowFilter,dropShadowFilter];
var newDropShadowFilter:DropShadowFilter = new DropShadowFilter();
newDropShadowFilter.distance = 60;
var myDropShadowIn:DropShadow = new DropShadow(mc,1,newDropShadowFilter);
myDropShadowIn.animationStyle(1000,Circ.easeInOut);
myDropShadowIn.addEventListener("onEnd",this);
myDropShadowIn.animate(0,100);
Example 5: (Example .swf) Filter classes can have properties that don't animate. You can set those properties either as start value to the flash.filters instance or to AnimationPackage's filter class itself as done in this example. When the animation is invoked the property will be applied. In the following we apply the knockout property directly to the DropShadow instance. Only distance, blurX and blurY will animate.
import flash.filters.DropShadowFilter; var filterEnd:DropShadowFilter = new DropShadowFilter(); filterEnd.distance = 8; filterEnd.blurX = 15; filterEnd.blurY = 15; var myDropShadow:DropShadow = new DropShadow(mc,filterEnd); myDropShadow.knockout = true; myDropShadow.animationStyle(3000,Sine.easeInOut); myDropShadow.animate(0,100);
Example 6: (Example .swf) To animate many movieclips the same way, this class also accepts an Array of movieclips instead of one movieclip. This way yields to a better performance than creating a new class instance for each movieclip you want to animate. Different start values of your movieclip properties are considered when animating multiple movieclips within one animation instance. Here, we animate a drop shadow in and out.
import flash.filters.DropShadowFilter;
var mcs:Array = new Array(mc1, mc2, mc3);
var dropShadowFilter:DropShadowFilter = new DropShadowFilter();
var myDropShadowIn:DropShadow = new DropShadow(mcs,dropShadowFilter);
myDropShadowIn.setOptimizationMode(true);
myDropShadowIn.animationStyle(1000,Circ.easeOut);
myDropShadowIn.addEventListener("onEnd",this);
myDropShadowIn.animate(0,100);
function onEnd(e:Object) {
var myDropShadowOut:DropShadow = new DropShadow(mcs,0,null);
myDropShadowOut.animationStyle(1000,Circ.easeIn);
myDropShadowOut.animate(0,100);
}
Example 7: (Example .swf) Showcase some of the DropShadow features in a Sequence.
import flash.filters.DropShadowFilter;
var filter1:DropShadowFilter = new DropShadowFilter();
var myDropShadow1:DropShadow = new DropShadow(mc,filter1);
var filter2:DropShadowFilter = new DropShadowFilter();
filter2.distance = 50;
var myDropShadow2:DropShadow = new DropShadow(mc,filter2);
myDropShadow2.setStartValues([dropShadowFilter1]);
var filter3:DropShadowFilter = new DropShadowFilter();
filter3.distance = 4;
var myDropShadow3:DropShadow = new DropShadow(mc,filter3);
myDropShadow3.setStartValues([dropShadowFilter2]);
var filter4:DropShadowFilter = new DropShadowFilter();
filter4.angle = 180;
var myDropShadow4:DropShadow = new DropShadow(mc,filter4);
myDropShadow4.setStartValues([dropShadowFilter3]);
var filter5:DropShadowFilter = new DropShadowFilter();
filter5.angle = 45;
filter5.blurX = 20;
filter5.blurY = 20;
var myDropShadow5:DropShadow = new DropShadow(mc,filter5);
myDropShadow5.setStartValues([dropShadowFilter4]);
var filter6:DropShadowFilter = new DropShadowFilter();
filter6.strength = 4;
filter6.alpha = 50;
var myDropShadow6:DropShadow = new DropShadow(mc,filter6);
myDropShadow6.setStartValues([dropShadowFilter5]);
var mySequence:Sequence = new Sequence();
mySequence.addChild(myDropShadow1);
mySequence.addChild(myDropShadow2);
mySequence.addChild(myDropShadow3);
mySequence.addChild(myDropShadow4);
mySequence.addChild(myDropShadow5);
mySequence.addChild(myDropShadow6);
mySequence.addEventListener("onEnd",this,"knockout");
mySequence.animationStyle(3000,Circ.easeInOut);
mySequence.animate(0,100);
var innerStatus:Text = new Text();
innerStatus.setText("inner "+false,0,0);
var knockoutStatus:Text = new Text();
knockoutStatus.setText("knockout "+false,0,15);
var hideObjectStatus:Text = new Text();
hideObjectStatus.setText("hideObject "+false,0,30);
function knockout(e:Object) {
innerStatus.updateText("inner "+false);
knockoutStatus.updateText("knockout "+true);
hideObjectStatus.updateText("hideObject "+false);
var children:Array = mySequence.getChildren();
for(var i:Number=0; i < children.length; i++) {
children[i].inner = false;
children[i].knockout = true;
children[i].hideObject = false;
}
mySequence.removeEventListener("onEnd",this,"knockout");
mySequence.addEventListener("onEnd",this,"inner");
mySequence.animate(0,100);
}
function inner(e:Object) {
innerStatus.updateText("inner "+true);
knockoutStatus.updateText("knockout "+false);
hideObjectStatus.updateText("hideObject "+false);
var children:Array = mySequence.getChildren();
for(var i:Number=0; i < children.length; i++) {
children[i].knockout = false;
children[i].inner = true;
children[i].hideObject = false;
}
mySequence.removeEventListener("onEnd",this,"inner");
mySequence.addEventListener("onEnd",this,"innerAndKnockout");
mySequence.animate(0,100);
}
function innerAndKnockout(e:Object) {
innerStatus.updateText("inner "+true);
knockoutStatus.updateText("knockout "+true);
hideObjectStatus.updateText("hideObject "+false);
var children:Array = mySequence.getChildren();
for(var i:Number=0; i < children.length; i++) {
children[i].inner = true;
children[i].knockout = true;
children[i].hideObject = false;
}
mySequence.removeEventListener("onEnd",this,"innerAndKnockout");
mySequence.addEventListener("onEnd",this,"hideObject");
mySequence.animate(0,100);
}
function hideObject(e:Object) {
innerStatus.updateText("inner "+false);
knockoutStatus.updateText("knockout "+false);
hideObjectStatus.updateText("hideObject "+true);
var children:Array = mySequence.getChildren();
for(var i:Number=0; i < children.length; i++) {
children[i].inner = false;
children[i].knockout = false;
children[i].hideObject = true;
}
mySequence.removeEventListener("onEnd",this,"hideObject");
mySequence.addEventListener("onEnd",this,"original");
mySequence.animate(0,100);
}
function original(e:Object) {
innerStatus.updateText("inner "+false);
knockoutStatus.updateText("knockout "+false);
hideObjectStatus.updateText("hideObject "+false);
var children:Array = mySequence.getChildren();
for(var i:Number=0; i < children.length; i++) {
children[i].inner = false;
children[i].knockout = false;
children[i].hideObject = false;
}
mySequence.removeEventListener("onEnd",this,"original");
mySequence.addEventListener("onEnd",this,"knockout");
mySequence.animate(0,100);
}
usage:
var myInstance:DropShadow = new DropShadow(mc);
var myInstance:DropShadow = new DropShadow(mc, filter, duration, callback);
var myInstance:DropShadow = new DropShadow(mc, filter, duration, easing, callback);
var myInstance:DropShadow = new DropShadow(mc, filterIndex, filter, duration, callback);
var myInstance:DropShadow = new DropShadow(mc, filterIndex, filter, duration, easing, callback);
var myInstance:DropShadow = new DropShadow(mc, values);
var myInstance:DropShadow = new DropShadow(mc, values, duration, callback);
var myInstance:DropShadow = new DropShadow(mc, values, duration, easing, callback);
var myInstance:DropShadow = new DropShadow(mc, filterIndex, values);
var myInstance:DropShadow = new DropShadow(mc, filterIndex, values, duration, callback);
var myInstance:DropShadow = new DropShadow(mc, filterIndex, values, duration, easing, callback);
var myInstance:DropShadow = new DropShadow(mcs);
var myInstance:DropShadow = new DropShadow(mcs, filter, duration, callback);
var myInstance:DropShadow = new DropShadow(mcs, filter, duration, easing, callback);
var myInstance:DropShadow = new DropShadow(mcs, filterIndex, filter, duration, callback);
var myInstance:DropShadow = new DropShadow(mcs, filterIndex, filter, duration, easing, callback);
var myInstance:DropShadow = new DropShadow(mcs, values);
var myInstance:DropShadow = new DropShadow(mcs, values, duration, callback);
var myInstance:DropShadow = new DropShadow(mcs, values, duration, easing, callback);
var myInstance:DropShadow = new DropShadow(mcs, filterIndex, values);
var myInstance:DropShadow = new DropShadow(mcs, filterIndex, values, duration, callback);
var myInstance:DropShadow = new DropShadow(mcs, filterIndex, values, duration, easing, callback);
parameters:
(Number)
(Array)
(Number)
(Number)
(Boolean)
(Boolean)
(Boolean)
(MovieClip) Movieclip to animate.
(Array) Array of Movieclips to animate.
(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:
usage: the same overloading applies to this method as described in the constructor. Just without the mc and mcs parameters.
returns: Void.
description: similar to the run() method. Offers start and end parameters.
usage:
myInstance.animate(start, end);
parameters:
returns: void
description: jumps to a specific step of the animation and stays there.
usage:
myInstance.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: rounds animation results to integers. (might be usefull for animating pixelfonts). Default is false.
usage:
myInstance.roundResult(rounded);
parameters:
true rounds the result. Animates with integers. Less accuracy. false animates with floating point numbers.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:
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: 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 value of the current tween. In degrees.
usage: myInstance.getStartValue();
returns: Number
description: sets the original, starting value of the current tween. In degrees.
usage: myInstance.setStartValue(startValue);
parameters:
returns: Boolean, indicates if the assignment was performed.
description: returns the targeted value of the current tween. In degrees.
usage: myInstance.getEndValue();
returns: Number
description: sets the targeted value of the current tween. In degrees.
usage: myInstance.setEndValue(endValue);
parameters:
returns: Boolean, indicates if the assignment was performed.
description: returns the current value of the current tween. In degrees.
usage: myInstance.getCurrentValue();
returns: Number
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.
value (Number) value to animate.
usage:
myInstance.addEventListener(event, listener);
myInstance.addEventListener(event, listener, handler);
parameters:
returns: Void.
description: Removes a listener from a subscribed event.
usage:
myInstance.removeEventListener(event, listener);
myInstance.removeEventListener(event, listener, handler);
parameters:
returns: Void.
description: GDispatcher specific feature. Removes all listeners for a specific event, or for all events.
usage:
myInstance.removeAllEventListeners();
myInstance.removeAllEventListeners(event);
parameters:
returns: Void.
description: GDispatcher specific feature. Checks if a listener is already subscribed to a certain event.
usage:
myInstance.eventListenerExists(event, listener);
myInstance.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