IN2*V2 - Mix-In Map
March 17, 2004

The V2 component architecture relies heavily on the "mix-in" design pattern. "Mix-ins" are a way to add functionality to ClassB from ClassA without the requirement of ClassB having to be a subclass (an inheritance relationship) of ClassA. This is perfect for ActionScript because of the dynamic nature of the language. You can basically add functionality to a class at any time without throwing a compiler error (which I guess can be good or bad depending on how you look at it :). Probably the most well known mix-in is EventDispatcher, which mixes methods for adding/removing listeners and dispatching events into other classes. There have been several good write ups on using and extending EventDispatcher including those by Ahmet, Grant (gDispatcher) and even me:)

However, there are a lot of places where methods are mixed into classes that can make it difficult for a developer to track down where certain functionality is located. For example, do you ever wonder how you can call "createClassObject" from any frame in your movie? Well, that method is actually mixed into MovieClip.prototype from the V2 architecture. There are also several methods mixed into Array.prototype and XMLNode.prototype.

Anyway, I put together a quick list of some of the mixed in methods I found in V2 (not exhaustive I'm sure). Maybe it'll come in handy sometime

View Mix-In Map

In this doc, I've listed broken down the classes that get methods mixed into them, the method that's mixed in, the class implementing the method, the class actually doing the mixing in, and the class that initializes this mix in process.

Posted by philter at 09:03 PM | Comments Disabled
Electrotank Pixel Cannon Game Source Code
March 09, 2004

Looks like Jesse and Jonas have linked to it already, but Jobe Makar has made the source files from his cool FF presentation available.

I noticed that there is an issue with the editor. It seems that the Flash movie scales when the window is resized, which it shouldn't (looks like the default settings might have changed between Flash Studio Pro 1 and 2). Anyway, I'm getting Jobe to update it as soon as he gets a chance. Until then, feel free to snoop around the code.

If I get some time, I'll do a write up on how it was built and some of the considerations made when I built it.

Also, check out this post on FlashKit, where Jobe discusses some of the thinking behind the game and multiplayer gaming in general. Get the inside scoop from the man himself :)

UPDATE: The resize issue has been fixed and can be downloaded from the URL above.

Posted by philter at 02:21 PM | Comments Disabled
IN2*V2 - Dispatching Mouse Events with "Button-Based" Components
March 07, 2004

Ever notice how a lot of the "button-based" components come with only a "click" event? Ever want to trigger an event when, say, the user rolls their mouse over a button? For example, maybe you want to have a tooltip appear when you roll over a button. Well, you could do something like this:

myBtn.onRollOver = function( ) {
 // display tooltip here
However, if you do this, you lose the nice hover effect on the button. Fortunately, there is a way to capture the roll over (as well as some of the other button events) in your button based components. The key lies in a seldom talked about class called "". This class will mix in all of the button events into UIEventDispatcher (which itself mixes into the component). This class also implements key events. The cool thing is that all you have to do to utilize this functionality in your component is to create a reference to it somewhere in your movie like so:

Now you should be able to listen for these events:

1) mouseOver
2) mouseOut
3) mouseDown
4) mouseUp

So you can do something like this (this example uses an AS2 Tooltip class created by Laiverd):


var tt:Tooltip = new Tooltip();
var bListener:Object = {};
bListener.mouseOver = function(evtObj) {
 tt.tipText = "Tooltip text goes here";
bListener.mouseOut = function(evtObj) {
This is a cool undocumented (AFAIK) feature, but just as cool is the fact that this added functionality costs you less than 1K in filesize.

Posted by philter at 11:05 PM | Comments Disabled
IN2*V2 - Nuggets on V2 Components
March 07, 2004

There has been a lot of talk lately surrounding the V2 component architecture...a lot of it regarding how it falls short in certain aspects. Having a measure of experience with the components myself, there are some very good things I see, and some areas that could use improvement. However, we have to live with the reality that this is what we have to work with for the time being, until someone else develops something to compete with it, and is available as open source (GhostWire's component sets are probably the closest you'll find right now). Having said that, the more information that can be shared in this arena, the better.

There has already been some good tidbits that have come out of the Flash community (Peter Hall even started putting together bug fixes that were going to be made publicly available) regarding the use of V2 components, and Nigel has put forth some effort into doing the same on his blog. In general though, there are still a lot of questions out there in terms of not only use components "out of the box" but also, how to customize and tweak components. Things like custom cellrenderers and skinning components are things are starting to get some coverage, but that people still have daily issues with.

IN2*V2 is just my attempt to share some of the things I've learned by "looking under the hood" of the V2 components (of course I have to qualify this by saying that I had no part in architecting or programming any of them, so MM can feel free to shoot down anything I write as inaccurate or not recommended practice). This is meant to share info, but also to hopefully start some discussion, which is always a good thing.

Plus, ever since Grant wrote a segment on issues with MX2004 which he called "FLAws" I've wanted to come up with some kind of cool play on words too. Unfortunately, IN2*V2 was the best I could do.

Anyway, it begins...

Posted by philter at 11:02 PM | Comments Disabled
Electrotank Giving Out Free Source Code at FFSF
March 02, 2004

Over the past month or so, I've been working on a project with Jobe Makar at Electrotank. He will be presenting at FlashForward SanFransisco (Friday March 5, 2:45-3:45pm) what sounds like a wicked session on Real-Time Multiplayer Games from one of the biggest names in multiplayer Flash games. Here is the blurb:

Multiplayer games have been possible with Flash for years, yet most multiplayer games have remained "turn-based." Flash game developers hope to create real-time multiplayer games such as shooters, racing games, and adventure games. In this session, Makar discusses major concepts that drive real-time multiplayer games, including the need to offload certain logic to the server. Several example games will be shown and one will be dissected. The complete source code to one real-time multiplayer game will be available for download.

He will be showing off a cool real-time Tank game and will be giving out (you heard it right) the source code after his session. For those of you who aren't able to make it, I may be posting a link to the source after FF is finished.

My contribution was a Level Editor for the game. Basically, it uses the game API that Jobe wrote and allows you to set up your own levels, export them as XML, and then play those levels with other people online. You can also re-open previously created levels and edit those. It's wrapped using Flash Studio Pro for all of the File IO stuff.

View Screenshot.

They have some big plans for future versions of this game (tons of features).

Be sure to go check out his session, and tell him I told you to go :) If only I could afford to go myself...

Posted by philter at 09:43 PM | Comments Disabled