Grant Skinner

The "g" in gskinner. Also the "skinner".

@gskinner

GTweeny: Lightweight (3kb) AS3 Tween Engine

GTweeny is GTween‘s lightweight younger sibling. It strips a lot of the secondary features of GTween (proxy, timing modes, etc) in favour of smaller file size. It is currently under 3kb, but I’m looking for feedback on this class: is a 1.5kb savings even worth it? Should I strip it down further to make it a 2kb core tweening class?

I’m leaning towards smaller, but I’m interested to hear what other developers think, particularly those working on banner ads. We don’t typically do banner ads at gskinner.com, so we are unlikely to use GTweeny internally.

Regardless of GTweeny’s future, this ~4kb 3D image gallery makes for a pretty decent demo. Flash player 10 required.

Continue reading →

GTweenTimeline: A Robust Virtual Timeline for Tweens

Probably the most exciting addition to GTween beta 5 is GTweenTimeline. This new class lets you easily build a virtual timeline of tweens, actions and labels, then control the whole thing as though it’s a single tween. You can even nest timelines inside each other, just like on the Flash timeline. Even better, it only adds about 1kb on top of GTween if you choose to use it.

GTweenTimeline extends GTween, which means you have the same interface, and can actually use a timeline instance as a normal tween, with a single target. You can repeat, reflect, reverse, pause, play, and jump to any point in your timeline, just like with any tween. Things get cool when you start sequencing other tweens, and tying in actions.

It gets even cooler when you pair it with the ability to synchronize frame based timeline animations with time based programmatic tweens. Suddenly you can integrate complex hand drawn effects into your code driven sequenced animation.

Here’s a look at some of the methods on GTweenTimeline:

// create a timeline, using an empty constructor because it isn't going to
// tween a target directly, and you can calculate the duration dynamically:
var timeline:GTweenTimeline = new GTweenTimeline();
// create a 2 second tween, and add it to the timeline to play at 0 seconds:
var circleTween:GTween = new GTween(circle, 2, {x: 200});
timeline.addTween(0, circleTween);
// create a 3 second tween, and add it to the timeline to start at 1.8 seconds.
timeline.addTween(1.8, new GTween(square, 3, {y: 300}) );
// add a callback at 2.2 seconds. This will execute the callback function with the specified parameters
// whenever the playback head crosses it (even in reverse). This is just like adding code to a frame
// on a timeline.
timeline.addCallback(2.2, myCallbackFunction, [param1, param2]);
// add a label at 1.8 seconds. This way you can jump to that point by name with gotoAndPlay or gotoAndStop.
timeline.addLabel(1.8, "squareStart");
timeline.gotoAndPlay("squareStart");
// calculate the timeline's duration from it's contents (tweens and callbacks).
// This way you don't have to remember to update it separately if you move things around.
timeline.calculateDuration();

Here’s a demo of it in action. All of the motion is done with tweening. The page numbers are shown with callbacks. Note that you can scrub the timeline, or even jump to any position instantly with the slider.

Continue reading →

GTween beta 5 Released! Major rewrite.

I’ve just released GTween beta 5. As I previously mentioned, this release is a significant rewrite to the full tweening engine. It stabilizes much of the positioning logic, and makes it more predictable. It also involved some very significant changes to the API, and the introduction of two important new classes: GTweenTimeline, and GTweeny.

GTween specific enhancements include a reduction in size to 4.5kb, a more predictable positioning model, slightly enhanced performance, the ability to specify repeat counts, full read/write access to start and end property values, the ability to lock starting properties, and a clean up of the API and code.

To read more about GTween, check out some demos, or download the library, visit gskinner.com/libraries/gtween/. To get more information on what’s changed, check out the version history or the API documentation.

This was a major rewrite, which pretty much guarantees that it has introduced new bugs. Please feel free to provide bug reports and feedback in the comments below. I’m hoping the next release will be final, once this version has seen some testing, bug fixing, and revisions based on feedback.

Here’s a super simple demo, showing GTween’s ability to deal with interrupted tweens. When you click around, it simply sets new end properties on each tween, and the tween adapts to the new values (and hey, it looks kind of cool). Check out the home page for more complex demos.

Continue reading →

Synchronized Timeline Animations in GTween

Another new feature I’ve added to GTween beta 5 is support for synchronizing timeline animations with scripted tweens. This lets you ensure that animations will remain synched even if you change the framerate of your FLA or if you pause, reverse, repeat, or otherwise manipulate your tweens.

Here’s a simple demo of it in action. The run cycle and fire are frame by frame animations, all other animation is done with GTween. Notice how the run cycle always lines up exactly the same with the motion tweens (despite everything being time based) and how it pauses along with the rest of the animation. The fire is not synchronized, so it will continue to play when the tween pauses, and is affected by framerate.

Also worth noting: the fire’s visibility is controlled through another new feature of beta 5, which improves on progress points. Best part, its only a few lines of fairly readable code for this whole demo.

Continue reading →

Preview: GTween beta 5, Now With More Sequencing.

GTween beta 5 was originally going to consist of minor bug fixes, but it’s quickly become a low level rewrite of the entire tweening library. I’ve simplified a lot of the logic, added new features, increased performance, improved reliability, made the code more readable, and even slightly reduced file size.

It will be another week or so before it is released (still fixing bugs and addressing edge cases), but I thought I would post a quick demo showing the much more powerful and easy to use sequencing features in beta 5.

All of this animation is done with GTween. Notice that you can move the slider, or click on its track to jump to any position in the sequence, and everything will display properly for that position. Also note the blur filters on the buttons as they tween into position.

Continue reading →

Editable Multi-Field Text Flow in Flash!

TextFlowPro enables you to flow a series of text fields together so that they act as a single text container, and still allow users to select, edit, and copy/paste text between the textfields. It should work with any text formatting, including different text formatting on different fields. It even supports tabIndex.

In terms of the sheer number of problems I had to solve to get things working, this is one of the most complex classes I have released for free. I was originally going to release this as a commercial component alongside the Spelling Plus Library, but I never got it to a level of quality that I was happy with. While I think I could iron out the remaining bugs, I still don’t think it would reflect the quality I want our commercial offerings to show – there are simply too many player bugs, edge cases, and niggling user experience problems.

However, it represents a huge amount of work, and I didn’t want to just leave it to rot, so I’m releasing it in the hopes people can do really cool things with it. At the very least, I hope it serves as a crash course in working with some of the text metrics APIs in player 9. I’m more than happy to answer any questions about how it works in the comments below.

Here are a couple of simple demos to show what it can do. These will be familiar to you if you’ve checked out TextFlowLite or TextFlow, but these add one small thing: editing!

Continue reading →

Flowing Text Between TextFields with Orphans/Widows

The TextFlow class allows you to flow text between text fields easily in Flash player 9. It has configurable support for orphans and widows (lines left at the start and end of a field respectively), as well as a simple API for getting the “overflow” from any field (or the whole flow).

It builds on the TextFlowLite class I posted a few days ago, sharing the same functionality and adding the following APIs:

// change orphans and widows (defaults to 2):
myTextFlow.orphans = 3;
myTextFlow.widows = 2;
// get any text that overflows past the bottom of the last text field in the flow:
// this can be handy for paging.
myTextFlow.getOverflow();
// get the text that overflows past the 2nd text field in the flow:
myTextFlow.getOverflow(1);
// change the flow's text fields:
myTextFlow.textFields = [fld1,fld2,fld3];

Here are a couple of demos. The first is nearly identical to the demo for TextFlowLite, but it takes advantage of the getOverflow method to display a “more” indicator when the text overflows the last field. It also has orphans and widows set to 2, so you should never have a single line of text dangling at the top or bottom of a field.

Continue reading →

Multi Column Text in Flash 9: TextFlowLite

Ever wanted to be able to display multi-column text in Flash? What about text that spans multiple arbitrary text fields? Sure, Adobe’s Text Layout Framework will let you display multi column text, but it’s still in beta, not to mention that it’s a big, robust framework.

TextFlowLite is a simple, light-weight class that works in Flash Player 9 with standard text fields. It takes one line of code to link any number of text fields together so that the overflow of each textfield runs into the next. Likewise, it’s one line of code to change the text, or reflow it if the textfields are resized.

import com.gskinner.text.TextFlowLite;
// set up the TextFlow, by default it will use the text of the first field:
var tfl:TextFlowLite = new TextFlowLite([fld1,fld2,fl3]);
...
// change the text:
tfl.text = "my new text";
...
// change the size of a field, and reflow the text:
fld1.height += 20;
tfl.reflow();

I built this class about a year and a half ago while working on the Spelling Plus Library, and had meant to release it much earlier. It is part of a set including TextFlow (adds support for orphans and widows), and TextFlowPro (which includes support for selection, editing, copy/paste). I will release the other two for free when I have time to retest and clean them up (hopefully later this week).

Here’s a simple demo:
Continue reading →