Skip to content
Actuate is a flexible, fast "tween" library
Haxe JavaScript ActionScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci First pass at enabling support for NPM Dec 19, 2017
lib-esm
lib Added es2015 modules under lib-esm/ Nov 21, 2018
scripts
src/motion Replace Lime-specific html5 conditionals with js Feb 4, 2019
test First pass at enabling support for NPM Dec 19, 2017
.gitignore Added es2015 modules under lib-esm/ Nov 21, 2018
.npmignore Rename Import, use relative path to sources on build Dec 20, 2017
LICENSE.md Update LICENSE.md Jan 2, 2019
README.md README: Expand the MotionPath example Jan 23, 2018
haxelib.json Improve NPM types, update version May 16, 2018
package.json Set sideEffects to lib-esm/motion/index.js so that it is not pruned b… Nov 21, 2018
webpack.common.js Better externals script May 17, 2018
webpack.dev.js Fix OpenFL externals May 16, 2018
webpack.prod.js Fix OpenFL externals May 16, 2018

README.md

MIT License Haxelib Version NPM Build Status

Actuate

Actuate is the best library for animating Haxe projects. Power through your everyday needs using no-nonsense, lightweight tweens, then extend when you need more, through the swappable custom actuator system

Installation

To install a release build:

haxelib install actuate

If you prefer to use development builds:

git clone https://github.com/jgranick/actuate
haxelib dev actuate actuate

To include Actuate in an OpenFL project, add <haxelib name="actuate" /> to your project.xml.

To add Actuate to a standard Haxe project, use -lib actuate in your HXML

Usage

It's simple to get started!

Actuate.tween (MySprite, 1, { alpha: 1 });

Actuate is designed to be simple to use and to take advantage strong code completion support in code editors like FlashDevelop, which means no more "reserved" keywords or "special" properties

Actuate.tween (MySprite, 1, { alpha: 1 }).onComplete (trace, "Hello World!");

Instance-based tweens can be a pain. When you don't keep track of each tween instance, you run the risk of creating conflicting tweens, which almost never turns out well. With first-class tween overwrite support, Actuate manages your tweens so you don't have to. Actuate also makes it simple to disable overwriting when you need to sequence multiple animations

Actuate.tween (MySprite, 1, { alpha: 1 });
Actuate.tween (MySprite, 1, { alpha: 0 }, false).delay (1);

It's also easy to stop, pause or resume your tweens, too

Actuate.stop (MySprite);
Actuate.stop (MySprite, "alpha");
Actuate.pauseAll ();
Actuate.pause (MySprite);
Actuate.pause (MySprite, MyOtherSprite);
Actuate.resumeAll ();
Actuate.resume (MySprite);
Actuate.resume (MySprite, MyOtherSprite);
Actuate.reset ();

There also are additional shortcuts you can use to help you be even more productive. For example, you can use Actuate to create quick tween-based timers for sequencing events

Actuate.timer (1).onComplete (trace, "Hello World!");

Or you can use the "apply" method to stop conflicting tweens and instantly set an object's properties

Actuate.apply (MySprite, { alpha: 1 });

Advanced Features

For advanced animations, you can also tween function calls instead of properties

Actuate.update (customResize, 1, [100, 100], [300, 300]);

Actuate also includes shortcuts for some special types of animation. Here is how you might apply a 50% tint using a color transform

Actuate.transform (MySprite, 1).color (0xFF0000, 0.5);

You can also control the volume and pan of a sound transform as well

Actuate.transform (MySprite, 1).sound (0.5, 1);
Actuate.transform (MySoundChannel, 1).sound (0.5, 1);

You can also tween filters. You can reference the filter by its class, or by the value of its index in the filter array, whichever is easier

Actuate.effects (MySprite, 1).filter (BlurFilter, { blurX: 10, blurY: 10 });

You even can create bezier curves, and complete motion paths, like in the Flash IDE. Chain multiple path commands together to create one solid path you can tween your objects across using the MotionPathActuator

var path = new MotionPath ()
  .bezier (100, 100, 50, 50)                 // quadratic, 1 control point
  .bezierN (200, 200, [50, 100], [50, 100])  // general, any number of control points
  .bezierSpline ([100, 100], [50, 50])       // spline, passing through the given points
  .line (20, 20);                            // linear
Actuate.motionPath (MySprite, 1, { x: path.x, y: path.y });

Tween Modifiers

Each tween Actuate creates can be modified with many different tween modifiers. You can link tween modifiers to add delay, complete handlers, or configure many different options about the way your tween behaves

autoVisible

Actuate.tween (MySprite, 1, { alpha: 1 }).autoVisible (false);

Changing the visible property results in better performance than only an alpha of zero, so the autoVisible modifier toggles the visible property automatically based upon the alpha value of the target. It is enabled by default, but it can be disabled if you choose

delay

Actuate.tween (MySprite, 1, { alpha: 1 }).delay (1);

Controls how many seconds should pass before your animation begins

ease

Actuate.tween (MySprite, 1, { alpha: 1 }).ease (Quad.easeOut);

Defines a custom easing equation for your animation. Actuate includes many popular easing functions in both standard and optimized formats. The default is Expo.easeOut, but you can change the default equation through Actuate.defaultEase

onComplete

Actuate.tween (MySprite, 1, { alpha: 1 }).onComplete (trace, "Tween finished");

Calls a function when the tween is finished. You can also define parameters to be used when calling the function

onRepeat

Actuate.tween (MySprite, 1, { alpha: 1 }).repeat().onRepeat (trace, ["Tween finished"]);

Calls a function when the tween repeats. You can also define parameters to be used when calling the function

onPause

Actuate.tween (MySprite, 1, { alpha: 1 }).repeat().onPause (trace, ["Tween paused"]);

Calls a function when the tween is paused. You can also define parameters to be used when calling the function

onResume

Actuate.tween (MySprite, 1, { alpha: 1 }).repeat().onResume (trace, ["Tween resumed"]);

Calls a function when the tween is resumed after being paused. You can also define parameters to be used when calling the function

onUpdate

Actuate.tween (MySprite, 1, { alpha: 1 }).onUpdate (trace, ["Tween updated"]);

Calls a function every time the tween updates. You can also define parameters to be used when calling the function

reflect

Actuate.tween (MySprite, 1, { alpha: 1 }).repeat ().reflect ();

Automatically reverses the animation every other time it is repeated. You must enable repeat in order to see any effect

repeat

Actuate.tween (MySprite, 1, { alpha: 1 }).repeat (10);

Runs your animation multiple times before it finishes. You can make your tween repeat indefinitely by passing no value, or you can define the number of times it should repeat

reverse

Actuate.tween (MySprite, 1, { alpha: 1 }).reverse ();

Reverses the direction of your tween

smartRotation

Actuate.tween (MySprite, 1, { rotation: 180 }).smartRotation ();

Rotation is circular, so it can be strange to animate. What should be positive one moment is negative the next. As a result, treating rotation like a standard tween will result in jerking once the signs change. Smart rotation always applies rotation in the nearest direction, alleviating this issue.

snapping

Actuate.tween (MySprite, 1, { alpha: 1 } ).snapping ();

Rounds all of your tween values

You can’t perform that action at this time.