Grant Skinner

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

@gskinner

Accessing EnterFrame Events in non-Display Objects

Once in a while you want to be able to have an object carry out actions on a frame interval. This is simple to accomplish when you’re working with a DisplayObject, because you can just subscribe to its ENTER_FRAME event directly, but there are times when you need this functionality in a non-display object without passing around a reference to a movieclip. In some cases, you can get by with using a Timer or interval, but this is often not ideal because you have no guarantee how often the event will fire in a single frame (a timer can fire multiple times, or not at all depending on how it synchs up with a frame cycle).

Turns out the solution is ridiculously simple: Just create a flash.display.Shape instance in your object, and subscribe to its ENTER_FRAME event. DisplayObjects do not have to be on the stage to generate enterFrame events.

StyleCollection for CS3 Components

The StyleCollection class lets you create groups of styles that are applied to and automatically updated on subscribing components. It supports both instance and renderer styles (setStyle and setRendererStyle respectively), and uses component introspection to apply only relevant styles to each component. StyleCollection exposes a robust interface, including a static interface that provides global access to named styles.

Continue reading →

Variable Scrollbar Width for CS3 Components

I’ve seen a few people asking for the ability to have variable scrollbar widths in the Flash CS3 component set. Unfortunately, it wasn’t something we were able to get in for the release, but since then I have put a bit of time into the feature, and believe I have it working satisfactorily with all components. I added two styles: scrollBarWidth and scrollArrowHeight. The former controls the width of the scroll bar (or height in a horizontal scroll bar), the latter controls the height of its arrows (allowing you to have irregularly sized arrows).

It’s important to note that this modification has not seen comprehensive testing, and it is not connected with Adobe in any way. Any mistakes are my own, and I’d appreciate if you can let me know about them in the comments.

Continue reading →

Flash Player 9 / AS3 Sound Crashing Bug

Here’s a simple bug in Flash Player 9 that crashes every browser I’ve tested it in. Simply call Sound.play(position) with an out of range position. For instance, the example below plays a 25 second sound with a starting position of 30,000 milliseconds.

This bug wasted an hour of my time while I tried to figure out why short tracks were crashing a computeSpectrum demo I built, but long tracks weren’t. It turned out I had set a starting position of 2 minutes to jump to a particularly dramatic part of one of the tracks I tested, and I had forgotten about it. Hopefully this post will save someone else the same pain.

This will almost definitely crash your browser, so check to make sure you don’t have anything important open. If it doesn’t crash, post in the comments with your browser / OS / player version.

Click here to turn off the internet (err, view the crash demo)

UPDATE Feb 29, 2008: This bug was fixed in a player 9 update (r60 I believe). Be aware that it can still affect your users, who may not have updated!

Free Extension: gAlign Panel

When doing design work in Flash (or laying out design elements), one of the most common panels to have open is the Align panel. It’s great for relative alignment and distribution, but we thought we could kick it up another couple notches. The result is the gAlign panel.

UPDATE

We have uploaded a new version of the gAlign panel, which works with shapes, drawing objects, and groups. Note that shapes will not work with the new drawing options.

VII. gAlign Panel

This panel has all the functionality of the Align panel (the top 3 rows), but with some much needed absolute spacing commands along the bottom. The “Distribute Spacing” commands use custom JSFL calls to distribute your elements based on the edges of the elements, rather than the registration points. For instance, refer to this image:

If you were to “Distribute” the items horizontally using Flash’s built in distribute, you would end up with the following result:

Using the new “Distribute Spacing” option in gAlign (and a spacing amount of “Auto”), you would get horizontal distribution based on the size of the elements.

Further, using the numeric spacing options, You can specify an absolute space between items. Applying a spacing of “2” to the first example would yield this result:

Download the gAlign Panel

Please feel free to let us know if you have any comments or suggestions.

There are a couple things to note.

  1. Apparently, the new align functions do not work with shapes. This is a limitation in flash.
  2. The “To Stage” toggle does not apply to the new align modes
  3. Flash treats each individual symbol position change as a seperate UNDO, instead of as a combined UNDO, since we use seperate JSFL calls to move each element.
  4. In order to align objects flush up against one another, you can distribute their spacing with a value of zero!
  5. This panel was developed for flash 7 and 8, but works in Flash 9.

Free Extension: AS3 String Utils

To continue the Extension goodness, here is an uber-handy AS3 class that we built the second we had access to AS3.

VI. AS3 String Utils

With the advent of regex in Actionscript, string methods become easier, and in some cases a lot faster. It also gave us a good exercise in AS3. This class is found in the com.chewtinfoil.utils package.
Oddly, Macromedia released a string utils class around the same time we built this, but we found that not only was there less methods, but they made no use of regex, and basically ported an AS2 version.
We have intended on releasing this one for some time, so without further ado, here it is:
Download this AS3 String Utils!
Please let us know if you find any problems, or have any other ideas for fancy string-abusing methods. See a complete API and example after the jump!
Continue reading →

Extension Melee (Part 4)

To mix things up a bit, this extension is not actually an extension, but a component. However, I think it’s fair to group it in our series of flash extensions (see part 1,2,and 3), due to its obvious usefulness 😛

VI. SimpleTabBox

The SimpleTabBox is an AS2 component we built a while back – as evidence, here is a screenshot of it in action in gProject. This is one of the components that I have always felt should have been part of the V2 component set, but for some reason, the closest Macromedia came was the release of the TabBar in one of the Devnet CDs (which was not very useful as all).
Download the Extension. Included is the component MXP, as well as the source classes, and an FLA with the skin assets.
This TabBox was designed with one thing in mind: An easy way to create a pleasant simple looking ViewStack in flash. I’m sure there are others out there, in fact Paul Ortchanian released an implementation a couple weeks ago.
I hope someone out there finds this useful. As with all of our other free extensions, feel free to let us know if you find bugs or have feature requests.
Continue reading →