Jump to content
Search Community

LinePath2D distribute vs. progress

Chris7777 test
Moderator Tag

Recommended Posts

Hi,

 

Just a quick question that we are trying to workout based on the documentation. Does the distribute function handle 0 & 1 differently than the progress function?

I am finding that path.distribute(mcArray, 0, 1) works as expected. mcArray[0] at the start, mcArray[1] at the middle, and mcArray[2] at the end.

 

But the minute I tween the paths property progress to say 1, two of the mc's overlap.

 

Please see the stripped down version of the documentation code below:

Note that the array contains 3 mc's, but 2 are overlapped. I also tried the documentation version (the 30 blue squares with the 1 red square) and found that is i changed the alpha of the blue cubes to, say 0.5, you can clearly see that two are overlapped.

 

Any help would be great, thanks.

 

import com.greensock.*;

import com.greensock.motionPaths.*;

import com.greensock.easing.*;

 

var path:LinePath2D = new LinePath2D([new Point(20, 20), new Point(300, 300)]);

addChild(path);

 

var a:Array = [createSquare(), createSquare(), createSquare()];

path.distribute(a, 0, 1);

 

TweenMax.to(path, 5, {progress:1, ease:Linear.easeNone});

 

function createSquare():Shape {

var s:Shape = new Shape();

s.graphics.beginFill(0xFF0000, 1);

s.graphics.drawRect(-10, -10, 20, 20);

s.alpha = 0.5;

s.graphics.endFill();

this.addChild(s);

return s;

}

Link to comment
Share on other sites

This is just a logic issue - you don't want your stuff distributed from 0 to 1 otherwise you'll get the overlap. Instead, you should figure out how much of a gap you'll need between each and adjust accordingly, like:

 

var gap:Number = 1 / (a.length + 1);
path.distribute(a, 0, 1 - gap);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...