[Tweener] why bezier?

Makc makc.the.great at gmail.com
Wed Feb 27 00:25:24 PST 2008


ok, people, nice to see you all so interested.... as the metalhead
says in 5th element, if you want something done, do it yourself.

here goes the code:

---8<---
import caurina.transitions.*
import caurina.transitions.properties.CurveModifiers;

CurveModifiers.init();

function makeBesierArray (p:Array):Array
{
	var bezier:Array = [];
	// convert all points between p[0] and p[last]
	for (var i:int = 1; i < p.length -2; i++)
	{
		var b1:Object = {}, b2:Object = {};
		// use p[0] properties to fill bezier array
		for (var prop:String in p[0])
		{
			b1[prop] = -p[i -1][prop]/6 +p[i][prop] +p[i +1][prop]/6;
			b2[prop] = +p[i][prop]/6 +p[i +1][prop] -p[i +2][prop]/6;
		}
		bezier.push (b1); bezier.push (b2);
	}
	return bezier;
}

// m0 to m6 are movie clips
var arr1 = [{x: m1.x, y:m1.y},
	{x:m1.x, y:m1.y}, {x:m2.x, y:m2.y}, {x:m3.x, y:m3.y}, {x:m4.x,
y:m4.y}, {x:m5.x, y:m5.y}, {x:m6.x, y:m6.y},
	{x:m6.x, y:m6.y}];
var arr2 = [{x: m6.x, y:m6.y},
	{x:m6.x, y:m6.y}, {x:m5.x, y:m5.y}, {x:m4.x, y:m4.y}, {x:m3.x,
y:m3.y}, {x:m2.x, y:m2.y}, {x:m1.x, y:m1.y},
	{x:m1.x, y:m1.y}];

function f1 ()
{
	m0.x = m1.x;
	m0.y = m1.y;
	Tweener.addTween(m0, {x:m6.x, y:m6.y, _bezier:makeBesierArray(arr1),
time:5, onComplete:f2, transition:"linear"});
}

function f2 ()
{
	m0.x = m6.x;
	m0.y = m6.y;
	Tweener.addTween(m0, {x:m1.x, y:m1.y, _bezier:makeBesierArray(arr2),
time:5, onComplete:f1, transition:"linear"});
}

f1();
---8<---

here goes the result (attached).

I hope my contibution will make its way into code base :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: b.swf
Type: application/x-shockwave-flash
Size: 16588 bytes
Desc: not available
Url : http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20080227/4bfdc8a2/attachment.swf 


More information about the Tweener mailing list