Arc Documentation
Author: Alex Uhlmann
Last Modified: 09/24/05 19:03:51
Summary
Arc class:
Arc Properties:
Arc Methods:
version: Documentation not provided.
description:
Arc is a class for drawing regular and elliptical arc segments and pie shaped wedges. Very useful for creating charts. Similar to java.awt.geom.Arc2D you can specify the closure type of the arc. Available closure types are:
If you specify a movieclip as first parameter, the shape will be drawn inside this movieclip. If you omit the mc parameter, the class will create a new movieclip in _root.apContainer_mc.OPEN = The closure type for an open arc with no path segments connecting the two ends of the arc segment. CHORD = The closure type for an arc closed by drawing a straight line segment from the start of the arc segment to the end of the arc segment. PIE = The closure type for an arc closed by drawing straight line segments from the start of the arc segment to the center of the full ellipse and from that point to the end of the arc segment. Default closure type is CHORD.
Example 1: (Example .swf) draw a 3/4 arc with default parameters.
Example 2: (Example .swf) draw an open arc, and animate it.var myArc:Arc = new Arc(275,200); myArc.setEndValue(270); myArc.draw();
var myArc:Arc = new Arc(275,200);
myArc.lineStyle(0x000000);
myArc.fillStyle(0xff0000);
myArc.setArcType("OPEN");
myArc.setStartValue(0);
myArc.setEndValue(270);
myArc.animate(0,100);
Example 3: (Example .swf) draw an arc with custom parameters.
Example 4: (Example .swf) draw an animated wedge with custom parameters, that continues to animated to full size and back.var myArc:Arc = new Arc(275,200,200,0,270,"PIE"); myArc.lineStyle(15,0xff0000,50); myArc.fillStyle(0xff0000,50); myArc.draw();
var myArc:Arc = new Arc(275,200,150,0,270);
myArc.setArcType("PIE");
myArc.lineStyle(2,0xff0000,50);
myArc.fillStyle(0xffff00,100);
myArc.animationStyle(2000,Sine.easeInOut,"onCallback");
myArc.animate(0,100);
myListener.onCallback = function(source, value)
{
if(value == 270) {
myArc.animate(100,0);
} else {
myArc.animate(0,100);
}
}
usage:
var myArc:Arc = new Arc();
var myArc:Arc = new Arc(x, y, radius, start, end, type);
var myArc:Arc = new Arc(mc, x, y, radius, start, end, type);
parameters:
(Number)(static) default property. Radius of the drawing. Defaults to 100.
(Number)(static) default property. Specifies the size of the drawing to begin with (in degrees). Negative values draw clockwise. Defaults to 0.
(Number)(static) default property. Specifies the size of the drawing to draw to (in degrees). Negative values draw clockwise. Defaults to 360.
(Number)(static) default property. Default closure type of arc is CHORD.
(MovieClip)(read only) Movieclip that contains the drawing.
(Number) Outline thickness.
(Number) Outline color of the drawing as hex number.
(Number) Outline transparency (alpha).
(Number) Fill color of the drawing.
(Number) Fill transparency.
(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 APCore class.
description: Draws regular and elliptical arc segments.
usage:
myArc.draw();
returns: Void.
description: Draws the shape without clearing the movieclip.
usage:
myInstance.drawBy();
returns: Void.
description: Draws the animated segments.
usage:
myArc.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: Returns the radius.
usage:
myArc.getRadius();
returns: Number that represents the radius in pixels.
description: Sets the radius of the drawing.
usage:
myArc.setRadius(radius);
parameters:
returns: Void.
description: deprecated. Use getStartValue instead.
usage:
myArc.getAngleStart();
returns: Number
description: deprecated. Use setStartValue instead.
usage:
myArc.setAngleStart(startAngle);
parameters:
returns: Void.
description: deprecated. Use getEndValue instead. Returns the angular extent of the arc.
usage:
myArc.getAngleExtent();
returns: Number that represents the angular extent of the arc in degrees.
description: deprecated. Use setEndValue instead. Sets the angular extent of this arc to the specified value.
usage:
myArc.setAngleExtent(angExt);
parameters:
returns: Void.
description: Returns the arc closure type of the arc: OPEN, CHORD, or PIE. See class description.
usage:
myArc.getArcType();
returns: String of the constant closure type defined in this class.
description: Sets the closure type of this arc to the specified value: OPEN, CHORD, or PIE. See class description.
usage:
myArc.setArcType(type);
parameters:
returns: Void.
description: define outline.
usage:
myArc.lineStyle();
myArc.lineStyle(lineThickness, lineRGB, lineAlpha);
parameters:
returns: Void.
description: define fill.
usage:
myArc.fillStyle();
myArc.fillStyle(fillRGB, fillAlpha);
parameters:
returns: Void.
description: Same interface as MovieClip.beginGradientFill(). See manual.
usage:
myShapeComposite.gradientStyle(fillType, colors, alphas, ratios, matrix);
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:
myArc.animationStyle(duration);
myArc.animationStyle(duration, callback);
myArc.animationStyle(duration, easing, callback);
parameters:
returns: Void.
description: Sets the registration point of the shape. Defaults to center. Top left is 0,0. The parameter object accepts either a position property with the value of "CENTER" or x and y properties of with coordinates as values of the registration point.
Example 1: Set the registration point of an ellipse to the upper left corner (0,0) instead of center.
var myEllipse:Ellipse = new Ellipse(275,200,100,50);
myEllipse.setRegistrationPoint( {x:0,y:0} );
myEllipse.draw();
internally AnimationPackage centers all shapes with
myInstance.setRegistrationPoint( {position:"CENTER"} );
usage:
myInstance.setRegistrationPoint(registrationObj);
parameters:
returns: Void.
description: removes all drawings. Identical to myInstance.movieclip.clear();
usage:
myInstance.clear();
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: 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 value of the current tween. In degrees.
usage: myInstance.getStartValue();
returns: Number
description: sets the original, starting value of the current tween.
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.
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:
myArc.addEventListener(event, listener);
myArc.addEventListener(event, listener, handler);
parameters:
returns: Void.
description: Removes a listener from a subscribed event.
usage:
myArc.removeEventListener(event, listener);
myArc.removeEventListener(event, listener, handler);
parameters:
returns: Void.
description: GDispatcher specific feature. Removes all listeners for a specific event, or for all events.
usage:
myArc.removeAllEventListeners();
myArc.removeAllEventListeners(event);
parameters:
returns: Void.
description: GDispatcher specific feature. Checks if a listener is already subscribed to a certain event.
usage:
myArc.eventListenerExists(event, listener);
myArc.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