Update on Go3D API – much more simple

Well, thanks to the guys on the GoASAP list, I’ve started coming up with an API that most of us are used to seeing/using with packages like Tweener and Fuse. The change is that you literally create the propertyChanges array for Tween3D in the arguments to pass to the constructor. No parsing has to be done in the constructor at all – just set the propertyChanges array to what’s passed in the constructor.

So, what used to look like this:
[as]
var tween:Tween3D = new Tween3D(target, 1, Equations.easeOutCubic, .5);
tween.x = 0;
tween.y = 50;
tween.rotationZ = 0;
tween.start();
[/as]

Now looks like this:
[as]
tween = new Tween3D(target, [Go3D.x(0), Go3D.y(50), Go3D.rotationZ(0)], 1, Equations.easeOutCubic, .5);
tween.start();
}[/as]

you can still create a Tween3D object and set the properties outside of the constructor if you want to of course.

The coolest part is that this abstracts the property objects. You can create 1 or multiple property classes that return property objects. So, in this sample, Go3D is a “properties class” that has static methods called x, y, z, rotationX, rotationY, rotationZ and they all return a Go3DProperty object that Tween3D uses. Now imagine that all of this is strongly typed, it’s fast and in a large scale development environment with many devs you could lock down what properties are tweenable as well as other logic and rules around doing this type of work. It’s complete abstracted out from the tweening/sequencing itself.

I’ve updated the rolodex files as well as put the new source out:

Go3D.zip
RolodexDemoGO3D.zip

Same demo, new code🙂

[kml_flashembed movie=”http://www.rockonflash.com/papervision3d/Go3D/RolodexGODemo.swf” width=”550″ height=”500″/]

The new createTween method now looks like this:

[as]
protected function createTween():void
{
sequence = new SequenceCA();
sequence.addEventListener(GoEvent.COMPLETE, handleSequenceComplete, false, 0, true);

tween_0 = new Tween3D(target, [Go3D.x(0), Go3D.y(50), Go3D.rotationZ(0)], 1, Equations.easeOutCubic);
sequence.addStep(tween_0);
sequence.lastStep.advance = new OnDurationComplete(.2); // advance early/overlap

tween_0b = new Tween3D(target, [Go3D.z(200)], 1, Equations.easeOutCubic);
sequence.addStep(tween_0b, true); // 2nd param groups it with previous step. param is “addToLastStep”

tween_1 = new Tween3D(target, [Go3D.x(-10), Go3D.y(85), Go3D.rotationZ(15)], 1, Equations.easeOutCubic);
sequence.addStep(tween_1);
sequence.lastStep.advance = new OnDurationComplete(.25); // advance early/overlap

tween_2 = new Tween3D(target, [Go3D.rotationX(0), Go3D.rotationY(0)], 1, Equations.easeOutBounce);
sequence.addStep(tween_2);
}
[/as]

  1. now you just need to tween the drop shadow to look like the card is falling onto the table
    🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s