Jump to content
Search Community

why cant I make dynamically paths or timelines seperate

flasp test
Moderator Tag

Recommended Posts

This is the same problem for TimelineMax and LinePath2D.

I simply cant get dynamically created timelines or paths to seperate like movieClips would.

In the example below I end up with one long path, which both shapes follows. What I need is the xml-generated paths to seperate, but what is the solution to that.

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.motionPaths.*;
import flash.geom.Point;
var s:Shape = new Shape();
s.graphics.beginFill(0xFF0000, 1);
s.graphics.drawRect(-10 / 2, -10 / 2, 10, 10);
s.graphics.endFill();
addChild(s);
var k:Shape = new Shape();
k.graphics.beginFill(0x0000FF, 1);
k.graphics.drawRect(-10 / 2, -10 / 2, 10, 10);
k.graphics.endFill();
addChild(k);
var points:Array=new Array();
var pointXML:XML=


0,0
100,100
320,150
550,400


300,30
250,100
380,150
50,400

;
function addMovement(mc,num,path:LinePath2D){
for each(var tmp:XML in pointXML.pointsettings[num].point) {
	var point:Array=tmp.toString().split(',');
	points.push(new Point(point[0],point[1]));
}
path = new LinePath2D(points);
path.addFollower(mc);
TweenMax.to(path, 20, {progress:2});
addChild(path);
}
var path0;
var path1;
addMovement(s,0,path0);
addMovement(k,1,path1);

Link to comment
Share on other sites

i'm not at all familiar with LinePath2D, but I think it may be because all your points are being placed in the same array:

 

points.push(new Point(point[0],point[1]));

 

 

I gather that your xml is divided into 2 separate nodes so that each of them is for a separate group of points forming a line.'

 

by putting all the newPoint()s into points, I think LinePath2D sees it as one long line.

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