I found something funny the other day when inspecting Flash Player’s built-in SimpleButton, a standard member of the display list. Or I thought it was standard.
SimpleButton isn’t a DisplayObjectContainer, so it doesn’t have methods like addChild() and getChild(). Instead it has convenient button states, such as the upState property, that contain children in a different way than DisplayObjectContainer. Which made me pause.
DisplayObject.parent is typed as a DisplayObjectContainer, both in the documentation and when analyzing the class through describeType() (reflection). So what is the value of the parent property when a display object is added to a SimpleButton? It’s the SimpleButton instance, a non-DisplayObjectContainer! Test all day long if you like, the parent property is very clearly typed to the container but just as clearly returning a different type. I now relinquish all claim to understanding the Flash Player and how it works.
I just got word that I can pick up our Flight t-shirts on Friday. Provided by ZenPrint these bad boys were designed by Bryant Robertson specifically for the 360|Flex Conference (if you haven’t registered yet you better get tickets). The ZenStudio design tool was built on an earlier version of Flight and the ZenPrint guys have graciously offered to sponsor the project at the conference. Thanks again, you guys rock! And of course props to our designer, we’re told we have the coolest logo of any other framework.
Flight is an application framework for ActionScript 3 (Flash & Flex) - you can read more about it on the website. My brother Jacob and I will be handing out the shirts and some print material at the conference where we’re making some announcements for the Flight Framework.
Hope to see you there!
I always wondered where I would end up using custom namespaces in ActionScript 3. Now that I’ve been using them I have found a few bugs and gotchas, tips and tricks, and now I generally understand namespaces better (or think I do).
(when reading this article it will help if you already have some familiarity with namespaces in Flash & Flex. To learn more about namespaces awesomeness, John Lindquist has an excellent video post that covers the concepts really well and goes into some advanced topics)
To start with I’d like to present a unique review of namespaces concepts (this isn’t pasted from the documentation, so it might be either 1-more helpful or 2-just plain wrong). There are reportedly 5 types of namespaces, but I’m going to say there are only 4 (this is the helpful/wrong portion).
(more…)
Jacob has been in an awesome groove lately, coding his own design engine because I’m too frustratingly indecisive to settle on my own implementation. I’ve been picking at a graphics-skinning-component-media library for way too long, always “just for fun”, so of course it hasn’t gone far. Now I’m jealous of his progress … I’m going to have another run at my own. I hate being inspired by competition (only), but it’s such a motivator - maybe from being the younger brother.
Gauntlet thrown, code spewing, I’m comin’ in!
And thanks Jac.
My daughter, the newest Mac addict. She’s pretending to work like her dad.
Delivered as promised. It has a smaller memory footprint, a faster clock-speed and, best of all, it’s 100% weak-referenced. Data binding is supposed to be light and unobtrusive. Now you can have the smallest ActionScript 3 binding available, released as a component of the open source Flight Framework.
Flight’s data binding is powerful and simple, consisting of two classes. A Binding object represents a single data source: a source object and a source-path, such as model and "user.userName". Any number of event listeners and object/property pairs can be registered with this single Binding instance, allowing each to update when the data source changes. This class may be useful for special needs, but you usually don’t deal with Binding directly.
The Bind class is the primary interface to Flight binding and is used much like you would use Flex BindingUtils. This class exposes a static API for adding and removing bindings and listeners. It can also be instantiated via MXML for special cases where you need weak-reference binding that curly-brace bindings just don’t support. Here’s an example of usage:
Binding via Static ActionScript API:
// Bind.addBinding(target:Object, targetPath:String, source:Object, sourcePath:String, twoWay:Boolean = false):Boolean Bind.addBinding(this, "userTxt.text", this, "model.user.userName"); |
Instance binds via MXML:
<!-- constructor: Bind(target:Object = null, targetPath:String = null, source:Object = null, sourcePath:String = null, twoWay:Boolean = false):void --> <flight:Bind targetPath="userTxt.text" sourcePath="model.user.userName"/> |
Visit the Google Project to download release 0.8.1 or higher.
One of those things that the browser has built in that you wish would just work in Flash - a simple TextField undo & redo. My brother recently released a really slick solution to the problem. It isn’t a UI component - it sits above the display list and works with all types of Flash TextFields: Flex components, Flash components, bare naked TextFields. It’s really small (1 manager and 3 command classes) and you attach it to the highest level display object necessary for a custom level of influence - so if you want the whole app to be effected then you attach it to the root.
Here’s what the API looks like:
var undoTextFields:UndoTextFields = new UndoTextFields();
undoTextFields.target = this;
Boom! done. (sound effect not included) And it works just like the browser - each TextField has its own undo/redo independent of the others.
NOTE:
The component uses the Flight Framework history without adopting the rest of the framework methodology. A great use of Flight, as it prescribes utility and a minimalistic approach to development. I’ll probably demo this utility at my upcoming presentation.
It isn’t easy for me to release code that isn’t finished, so I’ve had many projects come and go without ever seeing the light of day. But not Flight, not this time.
I’ve posted about Flight before: it’s a simple and powerful application framework in ranks with Cairngorm and some of the newer frameworks. Here’s an excerpt from Flight’s initial post:
The Flight Framework is the evolution of an ActionScript framework that has been around for a few years. It was a replacement to Cairngorm and was originally designed for web-based, design-centric applications such as logo makers and book builders. Even now the framework ships with the CommandHistory - an entire solution for undo and redo - and other practical utilities that strengthen its offering.
Flight Framework maintains an emphasis on supporting capable clients: Flex and Flash applications that are much more than just a pretty face to a server implementation. Through features like domains (modular MVC systems) and a prescribed structure, the framework transforms component scripting into real application development.
And such a nice conference! I’m pleased to say that I will be speaking at the best conference around for Flex and Flash developers. The presentations at this conference have real depth for developers, and this year looks like a great lineup: the schedule.
My topic is on a subject I’ve dealt with frequently. Over the last few years I’ve been heavily involved in building up design-centric tools and applications, all Flash/Flex based. Of course, one of the first requirements of these type of applications is undo and redo:
Undo History with Flight - level 200, Intermediate
Undo & redo is a core feature to many applications, yet it’s missing from your Flash and Flex projects. Learn how to easily add history to your applications with little effort. This session covers the concepts, benefits and the techniques of history management. It breaks down the complexity of undo & redo implementation into simple code, illustrating the use of the Command Pattern and providing the tools necessary to get up and running within minutes. This session is targeted toward intermediate developers, but will be a great overview of application history for beginners and non-programmers.
Also, there’s a pre-showing of the presentation at our next uFlash meeting. For everyone else, don’t forget to register for 360|Flex! The discount pricing for early registration is first come first serve.
I posted a rant on “releaseOutside” earlier this month - finally, here is the example and the code for making anything a Button in ActionScript 3. I’ve also added some really nice features since then. I realized after venting about dragOver, dragOut, and releaseOutside that, unless you built custom components in ActionScript 2, you probably have no idea what these events actually mean for a Button. So now, instead of imparting the boring details of exactly how a Button should work, I’ve implemented 3 new events: stateUp, stateOver and stateDown.
(more…)