Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Flash work?

Tags:

flash

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 :)

like image 334
Robert Gould Avatar asked Nov 27 '08 01:11

Robert Gould


2 Answers

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. ;)

like image 107
fenomas Avatar answered Oct 18 '22 21:10

fenomas


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.

like image 23
grapefrukt Avatar answered Oct 18 '22 21:10

grapefrukt