Package | com.greensock.motionPaths |
Class | public class RectanglePath2D |
Inheritance | RectanglePath2D MotionPath flash.display.Shape |
progress
property,
a value between 0 and 1 where 0 is at the beginning of the path (top left corner), and as the value increases, it
moves clockwise along the path so that 0.5 would be at the lower right corner, and 1 is all the way back at the
upper left corner of the path. So to tween a PathFollower along the path, you can simply tween its
progress
property. To tween ALL of the followers on the path at once, you can tween the
RectanglePath2D's progress
property. PathFollowers automatically wrap so that if the progress
value exceeds 1 it continues at the beginning of the path.lineStyle()
to adjust the color, thickness, and other attributes of the line that is drawn (or set the RectanglePath2D's
visible
property to false or don't add it to the display list if you don't want to see the line
at all). You can also adjust all of its properties like scaleX, scaleY, rotation, width, height, x,
and y
. That means you can tween those values as well to achieve very dynamic, complex effects
with ease.import com.greensock.*; import com.greensock.motionPaths.*; //create a rectangular motion path at coordinates x:25, y:25 with a width of 150 and a height of 100 var rect:RectanglePath2D = new RectanglePath2D(25, 25, 150, 100, false); //position the MovieClip "mc" at the beginning of the path (upper left corner), and reference the resulting PathFollower instance with a "follower" variable. var follower:PathFollower = rect.addFollower(mc, 0); //tween the follower clockwise along the path all the way to the end, one full revolution TweenLite.to(follower, 2, {progress:1}); //tween the follower counter-clockwise by using a negative progress value TweenLite.to(follower, 2, {progress:-1});
progress
property which will provide better performance than tweening each follower independently.Property | Defined by | ||
---|---|---|---|
centerOrigin : Boolean height of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation)
| RectanglePath2D | ||
followers : Array Returns an array of all PathFollower instances associated with this path
| MotionPath | ||
height : Number | MotionPath | ||
progress : Number
A value (typically between 0 and 1) that can be used to move all followers along the path.
| MotionPath | ||
rawHeight : Number height of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation)
| RectanglePath2D | ||
rawWidth : Number width of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation)
| RectanglePath2D | ||
rotation : Number | MotionPath | ||
scaleX : Number | MotionPath | ||
scaleY : Number | MotionPath | ||
targets : Array Returns an array of all target instances associated with the PathFollowers of this path
| MotionPath | ||
visible : Boolean | MotionPath | ||
width : Number | MotionPath | ||
x : Number | MotionPath | ||
y : Number | MotionPath |
Method | Defined by | ||
---|---|---|---|
RectanglePath2D(x:Number, y:Number, rawWidth:Number, rawHeight:Number, centerOrigin:Boolean = false)
Constructor
| RectanglePath2D | ||
addFollower(target:*, progress:Number = 0, autoRotate:Boolean = false, rotationOffset:Number = 0):PathFollower
Adds a follower to the path, optionally setting it to a particular progress position.
| MotionPath | ||
distribute(targets:Array = null, min:Number = 0, max:Number = 1, autoRotate:Boolean = false, rotationOffset:Number = 0):void
Distributes objects evenly along the MotionPath.
| MotionPath | ||
getFollower(target:Object):PathFollower
Returns the PathFollower instance associated with a particular target or null if none exists.
| MotionPath | ||
lineStyle(thickness:Number = 1, color:uint = 0x666666, alpha:Number = 1, pixelHinting:Boolean = false, scaleMode:String = "none", caps:String = null, joints:String = null, miterLimit:Number = 3, skipRedraw:Boolean = false):void
Sets the line style for the path which you will only see if you add the path to the display list
with something like addChild() and make sure the visible property is true.
| MotionPath | ||
removeAllFollowers():void
Removes all followers.
| MotionPath | ||
removeFollower(target:*):void
Removes the target as a follower.
| MotionPath | ||
renderObjectAt(target:Object, progress:Number, autoRotate:Boolean = false, rotationOffset:Number = 0):void
Positions any object with x and y properties on the path at a specific progress position.
| RectanglePath2D |
centerOrigin | property |
centerOrigin:Boolean
[read-write]height of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation)
Implementation public function get centerOrigin():Boolean
public function set centerOrigin(value:Boolean):void
rawHeight | property |
rawHeight:Number
[read-write]height of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation)
Implementation public function get rawHeight():Number
public function set rawHeight(value:Number):void
rawWidth | property |
rawWidth:Number
[read-write]width of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation)
Implementation public function get rawWidth():Number
public function set rawWidth(value:Number):void
RectanglePath2D | () | constructor |
public function RectanglePath2D(x:Number, y:Number, rawWidth:Number, rawHeight:Number, centerOrigin:Boolean = false)
Constructor
Parametersx:Number — The x coordinate of the origin of the rectangle (typically its top left corner unless centerOrigin is true )
|
|
y:Number — The y coordinate of the origin of the rectangle (typically its top left corner unless centerOrigin is true )
|
|
rawWidth:Number — The width of the rectangle in its unrotated and unscaled state
|
|
rawHeight:Number — The height of the rectangle in its unrotated and unscaled state
|
|
centerOrigin:Boolean (default = false ) — To position the origin (registration point around which transformations occur) at the center of the rectangle instead of its upper left corner, set centerOrigin to true (it is false by default).
|
renderObjectAt | () | method |
public override function renderObjectAt(target:Object, progress:Number, autoRotate:Boolean = false, rotationOffset:Number = 0):void
Positions any object with x and y properties on the path at a specific progress position.
For example, to position mc
in the middle of the path, you would do:
myPath.renderObjectAt(mc, 0.5);
Some paths have methods to translate other meaningful information into a progress value, like
for a CirclePath2D
you can get the progress associated with the 90-degree position with the
angleToPosition()
method like this:
myCircle.renderObjectAt(mc, myCircle.angleToProgress(90));
target:Object — The target object to position
|
|
progress:Number — The progress value (typically between 0 and 1 where 0 is the beginning of the path, 0.5 is in the middle, and 1 is at the end)
|
|
autoRotate:Boolean (default = false ) — When autoRotate is true , the target will automatically be rotated so that it is oriented to the angle of the path. 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.
|