This is G o o g l e's cache of http://www.flashsandy.org/forum/index.php?act=Print&client=printer&f=17&t=428 as retrieved on 2 Aug 2007 10:51:37 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:NLFg-drEJYAJ:www.flashsandy.org/forum/index.php%3Fact%3DPrint%26client%3Dprinter%26f%3D17%26t%3D428+act%3DPrint+%22index+php%22+-lofiversion+site:www.flashsandy.org&hl=en&ct=clnk&cd=31


Google is neither affiliated with the authors of this page nor responsible for its content.
These terms only appear in links pointing to this page: act print index php

Printable Version of Topic

Click here to view this topic in its original format

Sandy's Forum _ AS2 1.x versions _ Combining Interpolator's

Posted by: Stimpson Mar 30 2007, 01:27 PM

Hi There,

I'm having an issue I can't seem to work out.. combining Interpolator's (as in running them at the same time).

For a project I am putting together a rather cheesy deck of cards which need to be 3D animated (move back and rotate a bit for example). And to make things more complicated it needs to happen rollOver after the cards already are given a certain position and rotation in 3D, so I somehow needs to attach the new Interpolator's to the current transformations I guess.

Biggest problem I have is to combine the effects of translating and rotating for example since they cancel each other out. I only get 'distorted' animations, as in not the combined effects I would like to see.

Can anyone show me an example of this perhaps? Sandy seems great for my needs, but this would be a pose a real problem.

Thanks


Posted by: Petit Mar 30 2007, 01:58 PM

QUOTE(Stimpson @ Mar 30 2007, 01:27 PM) *

I'm having an issue I can't seem to work out.. combining Interpolator's (as in running them at the same time).

A TransformGroup can take only one interpolator, as far as I know.
This means you should have two TransformGroups to get both rotation and translation.
Here's my solution for rotating/translating a cube.
CODE
    var tTrans:TransformGroup = new TransformGroup();
    var tRot:TransformGroup = new TransformGroup();
    // Create a new Ease
    var easing = new Ease();
    // Set the easing type and method if you like
    // easing.easingOut().bounce(2,0.3);
    //easing.easingOut().elastic(3,0.4);
    // We create an interpolators to carry out the movements
    translation = new PositionInterpolator(easing.create(),100, new Vector(-80,0,0), new Vector(80,0,0));
    rotation = new RotationInterpolator( easing.create(),100, -90, 90);
    // Listen to the onEndEVENT to make a loop if you like
    rotation.addEventListener( InterpolationEvent.onEndEVENT, this, loop );
    // The interpolator is set in the transform group which will hold our pyramide
    tRot.setTransform( rotation );
    tTrans.setTransform(translation);
    // Add the rotation to the translation group ( test the opposite )
    tTrans.addChild( tRot );
    // Add the cube to the rotation group
    tRot.addChild( cube );
    // And finally the transformgroup to the rootGroup
    bg.addChild( tTrans );


This may not be exactly what you want. The order in which the rotation and translation is applied ( the parent/child relationship ) matters. To have them move simultaneously, you give both interpolators the same number of frames.
In my case, the rotation continues, because I', listening for the onEndEVENT and in its handler, I call the yoyo() method of that interpolator,

You can test drive my example: Attached File  CombineTrafo.swf ( 55.65k ) Number of downloads: 14

and download the source : Attached File  CombinedTrafo.as ( 5.14k ) Number of downloads: 2

Posted by: Stimpson Mar 30 2007, 02:06 PM

Petit, thanks for your quick reply. I am going to check out your example, your example seems to fit my needs, great.

One further question perhaps, is it possible to 'paste' this transformation on a already positioned object (in my case a Plane3D). I am guessing this works with plane3dinstance.getParent().getTransform(), although I am not sure how to combine that with your example.

Thanks!

Posted by: Petit Mar 30 2007, 02:10 PM

QUOTE(Stimpson @ Mar 30 2007, 02:06 PM) *

One further question perhaps, is it possible to 'paste' this transformation on a already positioned object (in my case a Plane3D).


Oops! There you broke me unsure.gif

Posted by: Stimpson Mar 30 2007, 02:14 PM

Yeah, that sounds a bit vague I guess wink.gif.

What I ment is how to combine your example with an onRollOverEVENT of a Plane3D object, in essence without using bg.addChild( tTrans ) I guess.

Posted by: Stimpson Mar 30 2007, 02:46 PM

I guess what I mean is how to apply the transformation on a Plane3D Object after it's own onRollOverEVENT smile.gif

I am guessing you can not use addChild on bg then since the object is already created and added earlier?

Posted by: Petit Mar 30 2007, 03:06 PM

QUOTE(Stimpson @ Mar 30 2007, 02:14 PM) *

Yeah, that sounds a bit vague I guess wink.gif.

No, perfectly understandable, but you lost me on the knowledge on ho to do it.
Now, I have a suggestion.
First I thought to start with the object as a child of the root group.
On the roll over, I'd remove it and add it to new interpolators ( new because otherwise they would have finished)

Then I thought that it would be possible to pause the interpolators and resume on roll over.
I knew that this is a bit tricky, because you cannot pause them immediately after you create them.

My solution is to create them as before, but call their pause() method in the first rendering cycle, like this:
Int the init() method I start listening for the onRenderEVENT.
CODE
    world.addEventListener(World3D.onRenderEVENT, this, pauseInterpolators);

The pauseInterpolators() event handler pauses the interpolators and remove the listener.
CODE
function pauseInterpolators(){
    translation.pause();
    rotation.pause();
    world.removeEventListener(World3D.onRenderEVENT, this, pauseInterpolators);
}

If the listener is not removed, the interpolators will be paused on each frame, and we don't want that.

Now we have to resume the interpolators at a mouse roll over ( or other event ).
To make this happen we first enable object events on our object ( to save resources, this is not the default. )
CODE
    cube.enableEvents(true);
    cube.addEventListener(ObjectEvent.onRollOverEVENT, this, moveIt);

The event handler for the onRollOverEVENT calls the resume() methods on the interpolators.
CODE
function moveIt(){
    translation.resume();
    rotation.resume();
}


There may be other and more elegant solutions, but this is what I could come up with.
Her's the start and stop variant: Attached File  CombinedTrafo.as ( 5.52k ) Number of downloads: 8

Posted by: Stimpson Mar 30 2007, 03:18 PM

Thanks for the idea, that might work. Altough I also need to roll back the transformation at a point.. and as a bonus I also need to round all objects up and rotate/translate them to another point (to minimize all the cards so to speak).

So I am guessing that is perhaps to complex. But thanks for the feedback, I am going to try it out.

Posted by: Petit Mar 30 2007, 09:49 PM

QUOTE(Stimpson @ Mar 30 2007, 03:18 PM) *

So I am guessing that is perhaps to complex. But thanks for the feedback, I am going to try it out.

Oh yeah! It's getting more complex by the minute.
About roll back of transformations, I guess you have seen that the interpolators have a yoyo() metdod as well as a redo() method, so roll back is built in.

In the Sandy 1.2 beta 2, there is a Sequence3D, that you might want to experiment with.
Being beta the 1.2 version lacks some functionality, but mabe you could fit the Sequence3D class to work for version 1.1.

There is also an updated version of Sandy 1.2 http://sandy.googlecode.com/svn/.
Look for sandy\as2\trunk\sources

In the SVN, the versions are in different states of development, and unstable by nature wink.gif

Posted by: Stimpson Mar 31 2007, 02:08 PM

Thanks Petit, I'm guessing this will work for now.

For the final minimizing of all cards I think I will recreate them on the spot they are and make new transformation (I hope I can correctly read back the current transformation values then wink.gif).

I will check out 1.2 also.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)