{"id":13744085,"url":"https://github.com/zeh/ztween","last_synced_at":"2026-01-10T18:55:44.431Z","repository":{"id":1233731,"uuid":"1168520","full_name":"zeh/ztween","owner":"zeh","description":"A simple tweening library. Its main feature is not having many features.","archived":true,"fork":false,"pushed_at":"2013-07-10T15:53:17.000Z","size":136,"stargazers_count":28,"open_issues_count":8,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-03T05:03:01.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-12-14T16:40:51.000Z","updated_at":"2023-09-06T00:50:58.000Z","dependencies_parsed_at":"2022-08-16T12:40:27.219Z","dependency_job_id":null,"html_url":"https://github.com/zeh/ztween","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fztween","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fztween/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fztween/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fztween/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeh","download_url":"https://codeload.github.com/zeh/ztween/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224802939,"owners_count":17372535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:01:02.853Z","updated_at":"2026-01-10T18:55:44.386Z","avatar_url":"https://github.com/zeh.png","language":"ActionScript","readme":"# ZTween\n\nZTween is a simple tweening engine written in AS3 for Flash Player version 10 and up. A \"tweening engine\" is something that takes a property and makes it go from an initial value to a target value in a given amount of time and with specific pre-programmed types of transition (linear, exponential, sine, etc). This can be used for animations and other kinds of timed behaviors in a Flash interface.\n\nZTween is built to be fast, small, have a minimal memory footprint, and be simple. The latter means that, as part of its design, ZTween does not employ any \"special\" tweening properties - it will only tween existing properties of objects, or variable values. It cannot create \"proxy\" functions like `scale` for `scaleX` and `scaleY`, auto-invisible set for `alpha`, auto-updater properties for `BitmapFilter` instances, etc.\n\n## Using ZTween\n\nZTween uses a syntax that is similar to modern AS3 engines. You basically `add` a new tween by using the line:\n\n\tZTween.add(target, properties, parameters);\n\n * `target` is the target object you want to change a property - any kind of object.\n * `properties` is an object containing the properties you want to tween (as the key), and their new values (as their value).\n * `parameters` is another object, this time containing some options about how the tween should be ran.\n\nHere are some examples:\n\n\t// Move sprite `myBox` to X position 10, in 1 second\n\tZTween.add(myBox, {x:10}, {time:1});\n\n\t// Fade sprite `myCircle` out (to alpha 0) in 2 seconds, while also scaling it to 200% of its original size\n\tZTween.add(myCircle, {alpha:0, scaleX:2, scaleY:2}, {time:2});\n\t\n\t// Set the `position` of an arbritary `slider` instance to 0.5 in 2 seconds, with a 1.5 second delay\n\tZTween.add(slider, {position:0.5}, {time:2, delay:1.5});\n\n\t// Moves sprite `myImage` to position X=10, Y=20, in 10 seconds, using an On/Out Cubic transition equation:\n\tZTween.add(myImage, {x:10, y:20}, {time:10, transition:Equations.cubicInOut});\n\nAnd so on and so forth. Notice that **any object** can be used as the target, and **any of its properties** can be used as part of a tweened property (as long as it's numeric).\n\t\n### Available parameters\n\nThese parameter names can be used as part of the parameters for a new tween:\n\n * `time`: time for the tween to be executed, in seconds *or* number of frames (see `useFrames`). Default is 0 (which does an immediate tween).\n * `delay`: delay to wait before the tween is executed, in seconds *or* number of frames (see `useFrames`). Default is 0.\n * `transition`: any function that takes one parameter `t` (0-1) and returns a new transformed `t` value to create different transition behaviors. This is used for tween update acceleration and deceleration. Common equations for this parameter are provided on the `Equations` class. Default is `Equations.none`, which produces a linear tween. See **Transitions**.\n * `onStart`: a function to be called when the tween starts. Works like a callback/event. See **Using signals**.\n * `onStartParams`: parameters for the `onStart` function, as an `Array` of items. See **Using signals**.\n * `onUpdate`: a function to be called when the tween update occurs. Works like a callback/event. See **Using signals**.\n * `onUpdateParams`: parameters for the `onUpdate` function, as an `Array` of items. See **Using signals**.\n * `onComplete`: a function to be called when the tween ends. Works like a callback/event. See **Using signals**.\n * `onCompleteParams`: parameters for the `onComplete` function, as an `Array` of items. See **Using signals**.\n \n * `useFrames`: a `Boolean` value that indicates whether the number used in `time` and `delay` represents frames. If set to `true`, this tween will have frame-based timing. If not, its duration time (and property update value) is based on real time (seconds). This dictates how time is controlled, not *when* updates are made; updates are always made on frame cycles. It is advised to always have this set as false, save on exceptional cases. Default is false.\n * TODO: Note: the above is not working on parameters; it only works when setting it on the tween property\n * paused\n \n### Transitions\n\nIn ZTween, the *transition* parameter defines the function used when updating the values. By default, the transition used is a linear function, that is, the property being tweened will go from the initial value to the target value in a uniform fashion. But by using different *transition* functions - usually called *easing* functions - you can have different update speeds, usually giving the appearance of acceleration or deceleration of the value being updated.\n\nAll the classic easing equations, as [introduced by Robert Penner](http://www.robertpenner.com/easing/), are bundled with ZTween. They are part of an additional class, `Equations`, and are as such:\n\n * `Equations.none`\n * `Equations.quadIn`\n * `Equations.quadOut`\n * `Equations.quadInOut`\n * `Equations.cubicIn`\n * `Equations.cubicOut`\n * `Equations.cubicInOut`\n * `Equations.quartIn`\n * `Equations.quartOut`\n * `Equations.quartInOut`\n * `Equations.quintIn`\n * `Equations.quintOut`\n * `Equations.quintInOut`\n * `Equations.sineIn`\n * `Equations.sineOut`\n * `Equations.sineInOut`\n * `Equations.expoIn`\n * `Equations.expoOut`\n * `Equations.expoInOut`\n * `Equations.circIn`\n * `Equations.circOut`\n * `Equations.circInOut`\n * `Equations.elasticIn`\n * `Equations.elasticOut`\n * `Equations.elasticInOut`\n * `Equations.backIn`\n * `Equations.backOut`\n * `Equations.backInOut`\n * `Equations.bounceIn`\n * `Equations.bounceOut`\n * `Equations.bounceInOut`\n\n### Using signals\n\nFor event-like behavior, ZTween uses *signals*, an approach based on Robert Penner's [AS3Signals](https://github.com/robertpenner/as3-signals) project. This allows faster, easy-to-use callbacks to functions to be fired when certain events occur with specific tweens.\n\nThe signals currently available for tweens are as such:\n\n * `onStart`: called when a tween starts\n * `onUpdate`: called when a tween update occurs\n * `onComplete`: called when a tween ends\n\nThere are two ways to define the signals used by a tween in ZTween. The first method is when creating a new tween:\n\n\tZTween.add(this, {x:10}, {time:2, onComplete:myOnCompleteFunction});`\n\nOr when assigning it to an existing ZTween instance:\n\n\tvar myTween:ZTween = ZTween.add(this, {x:10}, {time:2});\n\tmyTween.onComplete.add(myOnCompleteFunction);\n\nIn both of the cases above, the function `myOnCompleteFunction` will be called when the tween finishes executing.\n\nThe latter method has one advantage: you can attach several different functions to the same signal. For example:\n\n\tvar myTween:ZTween = ZTween.add(this, {x:10}, {time:2});\n\tmyTween.onComplete.add(myOnCompleteFunction);\n\tmyTween.onComplete.add(myOtherOnCompleteFunction);\n \nIn the above example, both `myOnCompleteFunction` and `myOtherOnCompleteFunction` will be called when a tween finishes executing.\n\n### Todo\n\n * Better documentation\n * Decide whether to allow new ZTween() constructor or not, or get rid of ZTween.add() in favor of it\n * Make sure useFrames work\n * Add equationParams\n * Properly document Equations.combined()\n * Not sure if all equations are working, since I cleaned them up a little bit and rewrote some of them\n","funding_links":[],"categories":["Frameworks"],"sub_categories":["Animation Framework"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeh%2Fztween","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeh%2Fztween","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeh%2Fztween/lists"}