MoveOnCurve Documentation

Author: Alex Uhlmann, Steve Schwarz
Last Modified: 09/24/05 19:04:21


Summary

MoveOnCurve class:

- description

MoveOnCurve Properties:

- duration
- easing
- callback

MoveOnCurve Methods:

- run
- animate
- goto
- animationStyle
- orientToPath
- orientOnPath
- roundResult
- forceEnd
- getOptimizationMode
- setOptimizationMode
- getTweenMode
- setTweenMode
- getDurationMode
- setDurationMode
- stop
- pause
- resume
- lock
- unlock
- isTweening
- getStartValue
- getEndValue
- getCurrentValue
- getCurrentPercentage
- getDurationElapsed
- getDurationRemaining
- addEventListener
- removeEventListener
- removeAllEventListeners
- eventListenerExists
- getID
- toString


MoveOnCurve class

version: Documentation not provided.

description:

Moves a movieclip on along a bezier curve with n controlpoints. With MoveOnCurve you can create bezier curves with an arbitrary length. The start and end points are the points on the curve. In contrary to i.e. MoveOnQuadCurve the MoveOnCurve class by default uses control points instead of points on the curve between the start and end points (anchor points).

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.

Example 1: (Example .swf) Draw a bezier curve with 11 control points. Loop a movieclip on it and draw the curve for visualisation. Attach a trail with infinite length and make it interruptible.

			
			var x1:Number = 350;
			var y1:Number = 50;
			var x2:Number = 50;
			var y2:Number = 50;
			var x3:Number = 50;
			var y3:Number = 200;
			var x4:Number = 850;
			var y4:Number = 200;
			var x5:Number = 350;
			var y5:Number = 350;
			var x6:Number = 50;
			var y6:Number = 350;
			var x7:Number = -550;
			var y7:Number = 500;
			var x8:Number = 600;
			var y8:Number = 600;
			var x9:Number = 650;
			var y9:Number = 500;
			var x10:Number = 650;
			var y10:Number = 50;
			var x11:Number = 350;
			var y11:Number = 50;
			
			var myStar:Star = new Star(275,200,20,10,6)
			myStar.lineStyle();
			myStar.fillStyle(0x9C3031);
			myStar.draw();
			
			var points:Array = new Array();
			points.push({x:x1, y:y1});
			points.push({x:x2, y:y2});
			points.push({x:x3, y:y3});
			points.push({x:x4, y:y4});
			points.push({x:x5, y:y5});
			points.push({x:x6, y:y6});
			points.push({x:x7, y:y7});
			points.push({x:x8, y:y8});
			points.push({x:x9, y:y9});
			points.push({x:x10, y:y10});
			points.push({x:x11, y:y11});
			
			var myMOC:MoveOnCurve = new MoveOnCurve(myStar.movieclip,points);
			myMOC.animationStyle(4000);
			myMOC.addEventListener("onEnd",this);
			function onEnd() {
				myMOC.animate(0,100);
			}
			myMOC.animate(0,100);
			
			var myCurve = new Curve(points);
			myCurve.lineStyle(6,0x8CA6BD);
			myCurve.animationStyle(4000);
			myCurve.animate(0,100);
			
			var myTrail:Trail = new Trail(myStar.movieclip);
			myTrail.attach(250,40,null);
			
			var myText:Text = new Text();
			myText.setText("Press the mouse to pause/resume the animation.");
			
			function onMouseDown() {
				if(myMOC.isTweening() == true) {
					myMOC.pause();
					myCurve.pause();
					myTrail.pause();
				} else {
					myMOC.resume();
					myCurve.resume();
					myTrail.resume();
				}
			}
			
Example 2: (Example .swf) Do the same like above just move and orientate the AP logo along the curve.
			...			
			var myMOC:MoveOnCurve = new MoveOnCurve(mc,points);
			myMOC.orientOnPath(true);
			myMOC.animationStyle(8000);
			myMOC.addEventListener("onEnd",this);
			function onEnd() {
				myMOC.animate(0,100);
			}
			myMOC.animate(0,100);
			
			var myTrail:Trail = new Trail(mc);
			myTrail.attach(250,40,null);
			...
			
Example 3: Draw a quadratic bezier curve (3 control points).
			
			var points:Array = new Array();
			points.push({x:0, y:0});
			points.push({x:275, y:200});
			points.push({x:550, y:0});
			
			var myMOC:MoveOnCurve = new MoveOnCurve(mc);
			myMOC.animationStyle(4000,Circ.easeInOut);
			myMOC.run(points);
			
Example 4: The alternative way is shorter. The same like above in one line.
	
			new MoveOnCurve(mc).run([{x:0,y:0},{x:275,y:200},{x:550,y:0}],4000,Circ.easeInOut);
			
Example 5: You can also specify the properties via the constructor. This might come in handy if you're using the Sequence or Parallel class. Take a look at their class documentations for more information. The animate() method and its start and end paremeters might also be useful.
			var points:Array = new Array();
			points.push({x:0, y:0});
			points.push({x:275, y:200});
			points.push({x:550, y:0});

			var myMOC:MoveOnCurve = new MoveOnCurve(mc,points,4000,Circ.easeInOut);
			myMOC.animate(0,100);
			

usage:

var myMOC:MoveOnCurve = new MoveOnCurve(mc);
var myMOC:MoveOnCurve = new MoveOnCurve(mc, points);
var myMOC:MoveOnCurve = new MoveOnCurve(mc, points, duration);
var myMOC:MoveOnCurve = new MoveOnCurve(mc, xpoints, duration, callback);
var myMOC:MoveOnCurve = new MoveOnCurve(mc, points, duration, easing, callback);

parameters:


MoveOnCurve Properties:

duration

(Number) Duration of animation in milliseconds or frames. Default is milliseconds.

easing

(Object) Easing equation in Robert Penner style. Default equation is Linear.easeNone. www.robertpenner.com/easing/

callback

(String) Function to invoke after animation. See APCore class.


MoveOnCurve Methods:

run

description: Documentation not provided.

usage:

myInstance.run();
myInstance.run(points);
myInstance.run(points, duration);
myInstance.run(points, duration, callback);
myInstance.run(points, duration, easing, callback);

parameters:

returns: void

animate

description: similar to the run() method. Offers start and end parameters.

usage:

myMOC.animate(start, end);

parameters:

returns: void

goto

description: jumps to a specific step of the animation and stays there.

usage:

instance.goto(percentage);

parameters:

returns: void

animationStyle

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.:

				var myRotation:Rotation = new Rotation(mc);
				myRotation.animationStyle(2000,[Back.easeOut,4]);
				myRotation.run(360);
				
See also "Customizable easing equations" in readme for more information.

usage:

myInstance.animationStyle(duration);
myInstance.animationStyle(duration, callback);
myInstance.animationStyle(duration, easing, callback);

parameters:

returns: Void.

orientToPath

description: offers the opportunity to rotate the object towards the curve while animating. Default is false. If true the object orientates towards the curve. If false the object's rotation will not be altered. See class documentation.

usage:

myInstance.orientToPath(rotateTo);

parameters:

returns: void

orientOnPath

description: offers the opportunity to rotate the object on the curve while animating. Default is false. If true the object orientates on the curve. If false the object's rotation will not be altered. See class documentation.

usage:

myInstance.orientToPath(rotateOn);

parameters:

returns: void

roundResult

description: rounds animation results to integers. (might be usefull for animating pixelfonts). Default is false.

usage:

myInstance.roundResult(event, listener);

parameters:

returns: Void.

forceEnd

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:

returns: Void.

getOptimizationMode

description: returns the optimization mode. See setOptimizationMode for more information.

usage: getOptimizationMode();

returns: Boolean

setOptimizationMode

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.

getTweenMode

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.

setTweenMode

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.

getDurationMode

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.

setDurationMode

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.

stop

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.

pause

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.

resume

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.

lock

description: locks the animation to prevent pausing, resuming and stopping. Default is unlocked.

usage: myInstance.lock();

returns: Void.

unlock

description: unlocks the animation to allow pausing, resuming and stopping. Default is unlocked.

usage: myInstance.unlock();

returns: Void.

isTweening

description: checks if the instance is currently animated.

usage: myInstance.isTweening();

returns: true if instance is tweening, false if instance is not tweening.

getStartValue

description: returns the original, starting value of the current tween. Percentage.

usage: myInstance.getStartValue();

returns: Number

getEndValue

description: returns the targeted value of the current tween. Percentage.

usage: myInstance.getEndValue();

returns: Number

getCurrentValue

description: returns the current value of the current tween. Percentage.

usage: myInstance.getCurrentValue();

returns: Number

getCurrentPercentage

description: returns the current state of the animation in percentage. Especially usefull in combination with goto().

usage: myInstance.getCurrentPercentage();

returns: Number

getDurationElapsed

description: returns the elapsed time or frames since the current tween started tweening.

usage: myInstance.getDurationElapsed();

returns: Number

getDurationRemaining

description: returns the remaining time or frames since the current tween started tweening.

usage: myInstance.getDurationRemaining();

returns: Number

addEventListener

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:

myMOC.addEventListener(event, listener);
myMOC.addEventListener(event, listener, handler);

parameters:

returns: Void.

removeEventListener

description: Removes a listener from a subscribed event.

usage:

myMOC.removeEventListener(event, listener);
myMOC.removeEventListener(event, listener, handler);

parameters:

returns: Void.

removeAllEventListeners

description: GDispatcher specific feature. Removes all listeners for a specific event, or for all events.

usage:

myMOC.removeAllEventListeners();
myMOC.removeAllEventListeners(event);

parameters:

returns: Void.

eventListenerExists

description: GDispatcher specific feature. Checks if a listener is already subscribed to a certain event.

usage:

myMOC.eventListenerExists(event, listener);
myMOC.eventListenerExists(event, listener, handler);

parameters:

returns: true if event exists on listener. false if event doesn't exist on listener.

getID

description: returns a unique ID of the instance. Usefull for associative arrays.

usage: myInstance.getID();

returns: Number

toString

description: returns the name of the class.

usage: myInstance.toString();

returns: String




generated with AS2docGenerator beta 0.5.3