Nov172008
Obviously, getting from displaying a keyboard-controlled object to a more “game-like” state is pretty easy. Here I’ve loaded an external PNG (that represents a spaceship of some kind) and attached it to a “ship” class instance. The left/right arrow keys control the object’s internal “rotation” value, and pressing the up arrow key moves the ship. The direction is determined by trigonometry functions; the movement vector along the x-axis is cos(ship.rotation) and the y-axis movement vector is sin(ship.rotation). (For example, if our ship is pointing straight up (90°), cos(90)=0 and sin(90)=1, so it’ll move straight up.)
Nov142008
So here’s the first real result of my toying Actionscript. If you’ll notice, the last post where I actually first downloaded the Flex 3 SDK was two months ago. It didn’t take me two months to do this, but rather took me that long to figure out when I could fit in extra programming time. The past two weeks I’ve started waking up super early, in order to study Actionscript before work. Anyway, I digress. This SWF was created with multiple classes, including a keyboard handler, main program class, and “entity” class (which in this case displays a blue box). Slowly figuring stuff out, like how to import graphics and associate them with an object, as well as event handling. Once the language-specific stuff gets figured out, things get easier because you know how to implement abstract algorithms/ideas. (Ah, just to reduce any potential confusion, you have to click the SWF in order to set focus, since it’s not embedded in the page. Apparently WordPress doesn’t like to embed SWFs…)
Sep142008
Started checking out Flex today. Been wanting to learn up something new recently, and Flex seems to bridge the gap between web development and a more traditional desktop application. So, what is Flex?
Flex is “Flash for programmers.” Previously, to create a Flash application, one had to utilize the timeline-based, GUI Flash authoring tool published by Adobe. While later versions of Flash allowed some pretty heavy programming through ActionScript, it was tedious and/or annoying to program through what was essentially a visual editor. Also, the program cost $900.
Flex is free from Adobe; they sell an IDE which supposedly makes things easier… it seems you can do drag ‘n drop application layouts with it, reminicent of Visual Basic. Anyway, I digress. A Flex application is made up of MXML (an XML-derivative used for layout) and ActionScript 3 (for logic). A very valid comparison would be to compare Flex to HTML (presentation) and PHP/ASP (logic).
I downloaded the SDK (read the release notes… no real “installation” per se, but you have to uninstall/reinstall your Flash player), and ran through the first two parts of this orientation. It starts you out with a basic application, then goes into tying Flex into other dynamic web languages such as PHP. Definitely web-centric for right now; I’m interested in looking into more graphical, ActionScript-centric tutorials.