Lets say you want to use Tweener to animate a camera in your PV3D Scene from z:0 to z:1400... but you want it to animate along a path with smooth bezier curves. Piece of cake! Here is how you do it.
Example (don't freak, there's a lot more comments than there is code):
//first you will need to import your Tweener classes
//in this case, also import the CurveModifiers class
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
//instantiate the CurveModifiers
CurveModifiers.init();
//create an Array that will hold the various bezier curve points
//the values indicate the that camera will swing from the left to the right
var curvePath:Array = new Array();
curvePath.push({x:400});
curvePath.push({x:-400});
curvePath.push({x:400});
curvePath.push({x:-400});
//you could also add in additional bezier curve point paramerts
//such as curvePath.push({x:400, y:200, z:200});
//set up a function to set the default position of the camera
//and to instantiate a tweener animation
//note that there is an additional parameter "_bezier" in the Tweener parameters
//in the "_bezier" parameter we passed in our curvePath array
function startTween():void
{
camera.z = -200;
Tweener.addTween(camera, {
x:0,
z:1400,
_bezier:curvePath,
time:12,
transition:"linear",
onComplete:startTween});
}
//lastly, call the startTween function to fire it off
//since the Tweener function has an onComplete parameter
//of startTween the animation will loop continuously
startTween();
View Example: click here
View Source: click here
Additional Info on Bezier Curves within Tweener:
Documentation / labs.zeh.com.br - Perfect Bezier Tween
skip to main |
skip to sidebar
Jim Foley's Brain. Flex, Flash, Papervision 3D, Swift 3D and other cool stuff.
Back on top ^
created by Nuvio | Webdesign
MAD VERTICES © 2008 Ken ahlin | Converted to XML Blogger Template by ThemeLib
Really usefull example, thank you so much.
Glad it was helpful. :-)
I love you!!! This is exactly what I have been digging around for!
Thanks for your Example. It was indeed usefull like someone said befor. Good to have your Blog on the Interwebs, sir! =)
Hey I'm using PV3D 2.0.883 For Flex. Apparently this class does not exist:
import org.papervision3d.cameras.FreeCamera3D;
Am I using the wrong version?
change FreeCamera3D to Camera3D on lines 8, 20, & 33.