Actuate .from gsap like? (SOLVED)


Is there any way to specify a “.from” parameter in Actuate in a similar way to gsap ?. It is a very convenient command since it allows you to have the sprites placed in their final positions and perform basic element animations “from” another relative (or absolute) position.

I know the apply method, but it is not the same, since Actuate does not memorize the values of positions (and other properties) of a given sprite.

Another example, if we want an animation to be played (having been reproduced once) of a series of elements from the beginning we have to initialize all the positions by hand.

Thank you

This could certainly be written as a utility method to work with Actuate, something like:

function from (target:Dynamic, duration:Float, properties:Dynamic) {
    var targetValues:Dynamic = {};
    for (field in Reflect.fields (properties)) {
        Reflect.setField (targetValues, field, Reflect.getProperty (target, field));
    Actuate.stop (target);
    Actuate.apply (target, properties);
    return Actuate.tween (target, duration, targetProperties);

I would be open to a contribution to Actuate, perhaps a tweenFrom method? However, it might not be necessary

Thanks Joshua, but our needs are not just a simple .from tweening.

What I am trying to program is a “helper class” for sequence animations more similar to gsap (not exactly the timeline with all the options, but with some basic ones):

  • You must memorize the original values of the displayObject: This is useful when the values of from are relative ("- = 50"), because otherwise, if we call the “from” a second time the displayObject will move from its position current, and not from the original.

  • There must be the possibility of “resetting” the sequence to the first position (taking into account the “from” positions and the original ones in case of not having “from” properties) for all the objects. This is useful in an application in which if we enter a new screen and have a sequence, the objects, they appear already placed in their real positions within that animation sequence. If it were not the case, we would reach the screen and when the animation started, the objects would “jump” a little until they were placed in their position within the animation.

  • There must also be the possibility of, at least, controlling the end of animation (onComplete) through a dispatched event.

I have all this working in a class that I call ActuateSequence.hx. It is not very clean yet and is in beta (there will be bugs and things that are still missing, for sure). But “it works” for a series of use cases. (I want to share it when it is a bit more finalized)

But now I have realized that in Actuate I believe that there is no possibility of having more than one sequence of objects created at the same time. Because the commands are general for all objects (“pauseAll”, “resumeAll”).

For basic needs, what I am developing may be valid. Now, if we have some other tweening in addition to the general animation sequences, we could not run it with Actuate, since it would overwrite the sequence … I think …

Thanks Joshua,

Ok, I think I got it!

I have uploaded to github the Helper Class that I was telling you, along with an implementation example in Main.hx. It’s in beta and not very polished, so there will be bugs.

In view of the fact that there are very few complete tweening libraries for haxe, I have decided to do this which, although it is not a Timeline itself (cannot position the playHead), covers some of our needs.

You can add animations to the sequence in a more similar manner to gsap.
Can play, pause, stop (rewind to beginning), etc
Can control end of play by Dispatching Event onComplete

I hope some of you will find it useful.