Package | com.greensock.motionPaths |
Class | public class PathFollower |
progress
property that manages positioning
the target on the path accordingly. The progress
property is a value between
0 and 1 where 0 is at the beginning of the path, 0.5 is in the middle, and 1 is at the end.
When the follower's autoRotate
property is true
, the target will be
rotated in relation to the path that it is following. import com.greensock.*; import com.greensock.motionPaths.*; //create a circle motion path at coordinates x:150, y:150 with a radius of 100 var circle:Circle2D = new Circle2D(150, 150, 100); //make the MovieClip "mc" follow the circle and start at a position of 90 degrees (this returns a PathFollower instance) var follower:PathFollower = circle.addFollower(mc, circle.angleToProgress(90), true); //tween the follower clockwise along the path to 315 degrees TweenLite.to(follower, 2, {progress:circle.followerTween(follower, 315, Direction.CLOCKWISE)}); //tween the follower counter-clockwise to 200 degrees and add an extra revolution TweenLite.to(follower, 2, {progress:circle.followerTween(follower, 200, Direction.COUNTER_CLOCKWISE, 1)});
progress
property which will provide better performance than tweening each follower independently.Property | Defined by | ||
---|---|---|---|
autoRotate : Boolean When
autoRotate is true , the follower will automatically be rotated so that it is oriented to the angle of the path that it is following. | PathFollower | ||
path : MotionPath
The MotionPath instance that this PathFollower should follow
| PathFollower | ||
progress : Number
A value (typically between 0 and 1) that can be used to move all followers along the path.
| PathFollower | ||
rotationOffset : Number When
autoRotate is true , this value will always be added to the resulting rotation of the target. | PathFollower | ||
target : Object The target object associated with the PathFollower (like a Sprite, MovieClip, Point, etc.).
| PathFollower |
Method | Defined by | ||
---|---|---|---|
PathFollower(target:Object, autoRotate:Boolean = false, rotationOffset:Number = 0)
Constructor
| PathFollower |
autoRotate | property |
public var autoRotate:Boolean
When autoRotate
is true
, the follower will automatically be rotated so that it is oriented to the angle of the path that it is following. To offset this value (like to always add 90 degrees for example), use the rotationOffset
property.
path | property |
public var path:MotionPath
The MotionPath instance that this PathFollower should follow
progress | property |
progress:Number
[read-write]
A value (typically between 0 and 1) that can be used to move all followers along the path. You can tween to
values that are greater than 1 or less than 0 but the values are simply wrapped. So, for example, setting
progress
to 1.2 is the same as setting it to 0.2 and -0.2 is the same as 0.8. If your goal is to
tween the PathFollower around a Circle2D twice completely, you could just add 2 to the progress
value or use a relative value in the tween, like:
TweenLite.to(myFollower, 5, {progress:"2"}); //or myFollower.progress + 2
public function get progress():Number
public function set progress(value:Number):void
rotationOffset | property |
public var rotationOffset:Number
When autoRotate
is true
, this value will always be added to the resulting rotation
of the target.
target | property |
public var target:Object
The target object associated with the PathFollower (like a Sprite, MovieClip, Point, etc.). The object must have x and y properties.
PathFollower | () | constructor |
public function PathFollower(target:Object, autoRotate:Boolean = false, rotationOffset:Number = 0)
Constructor
Parameterstarget:Object — The target object associated with the PathFollower (like a Sprite, MovieClip, Point, etc.). The object must have x and y properties.
|
|
autoRotate:Boolean (default = false ) — When autoRotate is true , the follower will automatically be rotated so that it is oriented to the angle of the path that it is following. To offset this value (like to always add 90 degrees for example), use the rotationOffset property.
|
|
rotationOffset:Number (default = 0 ) — When autoRotate is true , this value will always be added to the resulting rotation of the target.
|