Bezier Moving Path Points

1 view
Skip to first unread message

serkan

unread,
Jul 23, 2009, 7:52:26 AM7/23/09
to Tweensy
Hi i have made an example to see how to make a bezier tween with
moving points but i have a interesting problem.

In the below code, you can see in the comments,when i define the
bezier2D as a global var, it throws an error. So i have to define 2
beziers one inside and one outside and, aply the local one to the
global one.

Regards,
Serkan

package {
import com.flashdynamix.motion.guides.Bezier2D;
import com.flashdynamix.motion.TweensyGroup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Point;
import fl.transitions.easing.Regular;
import com.flashdynamix.motion.TweensyTimeline;

public class testBezierTweensy extends MovieClip {


//I have to define two beziers inside and outside, if i try to just
define a global bezier it throws an error
var bezo:Bezier2D;

//visual references to see where the bezier points are. Nodes are
just movieClips containing a cross.
var n01:node = new node();
var n02:node = new node();
var n03:node = new node();


public function testBezierTweensy():void
{
var tween:TweensyGroup = new TweensyGroup();

//mc is just a movieClip containing a sphere
var bezier:Bezier2D = new Bezier2D(mc, true, false, true);

//i need a work around like this to move the middle bezier point
bezo = bezier;

initNodes();

bezier.push(new Point(n01.x, n01.y));
bezier.push(new Point(n02.x, n02.y));
bezier.push(new Point(n03.x, n03.y));

tween.to(bezier, { position:1 }, 5, Regular.easeInOut).repeatType
= TweensyTimeline.YOYO;

stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
}


private function mouseMove(event:MouseEvent):void
{
n02.x = bezo.path[1].x = event.stageX;
n02.y = bezo.path[1].y = event.stageY;

}

private function initNodes():void
{
var n01:node = new node();
var n02:node = new node();
var n03:node = new node();

addChild(n01);
addChild(n02);
addChild(n03);

n01.x = 0;
n03.x = 550;
n01.y = n03.y = 200;

}
}
}
Reply all
Reply to author
Forward
0 new messages