views:

632

answers:

3

Right now I'm developing a small canvas oriented 2D graphics engine for a game, and have been looking into several sources for hints to apply to my system's design. But obviously the most battle proven solution out there is flash, so I was wondering how is Flash architectured. I found some sources about Flash's workings, but most are very basic and oriented towards designers and artists, but I'd like to learn more about the guts of the system. My next step is to download Flex's source code and wade through it, but before that I'd like to have a "guide" to make the best of my time in the code base. Any suggestions of good online resources and articles?

Thanks!

Edit: To make it more clear, I'm looking for the inner workings of Flash because my goal here is to make something similar to Flash, but not as powerful of course, that works in a browser without plugins. Alas pure HTML+Javascript.

Also the reason I'm not using Flash as such is because it doesn't fulfill my requirements (free + no plugin), and because I don't have Flash support on my target platforms, besides I'm reinventing the wheel here for fun and self-education. Oh and I already know how to use Flash :)

+6  A: 

Well, at the root of your Flash content is a stage object (an instance of the Stage class). That stage is the root node of a tree of display objects, any of which can contain graphical assets (lines, text fields, etc.) or other display objects. How Flash "works" is that, X times per second, the Flash player draws that entire display tree onto the screen. The player also collects user input (KeyboardEvents, etc.) from the OS and delivers them to any object that has registered for them.

Your job as a content creator, then, is to populate this Stage with children (of type DisplayObject or any subclass), which the Flash engine will draw onto the screen for you. You can populate it with low-level children like Sprite and MovieClip and TextField, which are the basic building blocks of Flash content, or you can instantiate things like ScrollBar or DataGrid, which are higher-level components with the usual complex inner workings.

And of course you can extend any of these classes to include your own custom visuals or class logic, or create non-visual classes that aren't part of the display tree. And you can load in other flash content, or make HTTP connections, etc. etc.

That's all assuming you mean AS3. Does that help? If not you're going to have to make your question more specific. ;)

fenomas
Yes it helps, but if you had a few good resource links it'd be even better.
Robert Gould
Um, I should've been more specific, your links to the docs are a great help, but I was wondering if there was some white-papers or document along those lines
Robert Gould
I see where you're going. Things generally are very similar to the FL chart you linked (but with fewer "Device XXX" boxes, and I think "Device OS" and "Frame buffer" would be partially replaced by the browser plugin hooks). But I don't know of any particular white papers or public specs.
fenomas
A: 

The best link I've found (quite pathetic though) is this one:

Architecture of Flash Lite

Robert Gould
+1  A: 

If you're going to make a game, stay away from Flex. And honestly, looking at the source code for that is likely to confuse you more than help you. Flex is very good for GUI intensive applications, and helps speed up the development of such products. It is, however, not very fast nor especially well suited for games.

One of the major advantages of Flash is that you don't really have to care about the "inner workings" very much, though a basic understanding of them naturally helps.

Flash Lite is rather different from it's full grown bigger brother, so don't put too much care into that.

Also, for the love of god, learn Actionscript 3.0 and stay away from Actionscript 2. 3.0 is way better in every conceivable way (atleast for us coders).

EDIT: To clarify: There are some confusion regarding the term Flash. There's three parts to it all, the plugin that runs in your browser, the "technology itself" and the Authoring tool. All of these are simply called Flash. Flex even more confusing. It is a framework that runs on top of Flash. Much like say, Swing for Java (I've never used that so that comparison might be totally wrong). All you can do in Flex is also doable in Flash. Flex is free open source, but the IDE, Flex Builder is not. Flex Builder is very useful even if you're doing "pure" actionscript projects. But there are also many cheaper alternatives. I personally prefer FlashDevelop.

grapefrukt
The flex environment is probably quite good for building as3 games in but yeah the flex library isn't what you need
John Burton
Yes I agree, I just read through some of the Flex code, but it wasn't at all what I was looking for. I mistakenly imagined the Flash engine's code was included in Flex's OpenSource SDK, but it wasn'
Robert Gould
Note that while the Flash Player overall is not open source, Adobe recently OS-ed the AS3 engine itself, which ought to expose the essential architecture. Google "mozilla tamarin" for info.
fenomas