So I'm getting into web development now and thus have to go with other languages and such, and of course Flash is one as it is capable of some fancy and exciting things, but just to help me with arguments later on and just so that I know, is Flash considered OOP or Object Oriented Programming?
Thanks in advance
It's like Unreal games use UnrealScript, but they could just as well not use any scripting languages, or use LUA, or Python, etc. You wouldn't say Unreal Tournament 3 is OOP.
That's going a little too far considering the Flash API's interface is exclusive to ActionScript, hehe. Most people know what you mean anyway.
Yep, actionscript uses classes and objects.
In Flash CSx you'll use ActionScript 3 which is similar to C#, a little bit Javaish, more OOP semantics support and more restrictive than ActionScript 2.
This restrictiveness even lead us to program with a better performance unlike the oldie.
Btw OOP is paradigm, not a programming language specific.
If you want to do OOP for the web - look into Adobe Flex. It's just a collection of libraries for Actionscript, but you can write programs that are very java-esque or C#-esque and compile them to swfs. Very cool platform (and very OO) - it's what my day job is in, and I like it a lot.
I think AS3 is more than "a little" like Java. The API looks like it was copied line for line in a lot of places. C# takes after Java and C++ though, so actually they are all very similar.
ActionScript 2.0 to 3.0 are all object oriented versions of the 'language' However there are no destructors for classes which can be a pain. Also everything is a reference since there are no pointers...which means essentially everything is a pointer. But in the object oriented department it does fit the mold of many languages like it. It allows for maximum 1 derivation from a base (but there are ways around this), has access restrictions (public, private), has properties similar to C#, and has the same layout as C# in that there are no separate header files for the classes.
Where ActionScript starts to fall apart in the object oriented department is how it interacts with objects on the stage. I guess if your SWF is going to be running inside of Adobe Flash this probably will not be an issue. I probably should not go any further with that discussion though.
So while AS is object oriented depending on what is playing the SWF or what you are doing on the timeline in the FLA you may not be able to be as object oriented as you would like for performance reasons. AS overall feels very slow. I believe something like cos or sin takes on the order of 157 ms to compute in AS.
I've heard about Flash's performance issues, yet I think it's the best solution for web stuff AND is nice to work with, I mean the application itself ;)
The public/private thing made it even more exciting as it's awesome, but if it lacks destructors ... I'll just have to live with that
IMHO, if you refuse to work on the timeline and instead code your SWFs entirely in the code editor, you will appreciate the language more.
I found the timeline a major detractor from AS3 since it forces you to program things differently and apply a lot less elements of the language. There could be an advantage to it (faster development for instance). But my experience told me that to not be the case at all. The lack of features becomes so significant, that you really will only want to use the timeline for small and simple projects.
That said, you will really want to take your apprenticeship from the ground up. So, do not take this advise at the moment. Just keep in mind that invariably your focus should shift from the timeline to the script language as soon as you feel comfortable with timeline-based SWF programming. Despite its sins, the timeline will provide you with fundamental concepts that are needed to better understand pure AS3 programming in the future.
I have done exactly one small simple flash app, using perl ming; the actionscript part was confined to simple arithmetic and for/while/if constructs. But one thing I learned doing that is that an .swf is just serialized data like any other image (of course, I guess it could not really be anything else). The structure of this file is not a secret (I have it in a book, I haven't looked around on line) so you could (maybe I will*) write a C program -- or whatever -- to assemble .swf files based on your input. Part of the file is the actionscript for use by the flash player, this may (or may not) be precompiled into an intermediate form, I will have to dig deeper -- but curious as to whether anyone else has tried something like this?
* more likely I will just check out flex, but I kind of like this idea.
Actually a year ago Adobe released the specification for the SWF format. Before that there were indeed programs that cracked the format and released their own compilers/players/assembler/disassembler/etc. It's actually not exactly serialized, it's compiled into bytecode (like Python, Java, etc.). It can be quite complex sometimes, which you'd see if you looked into an encrypted SWF file. I'm hoping the bigger topic in the future will be a comprehensive open source solution to a cross-language, hardware-accelerated Flash API. The creators of Scaleform reverse engineered swf, re-created AS2 VM, re-binded API, and attached it to their GFX engine before the specification was even released. Wicked awesome, but expensive commercial license. They really own that market. Most flash solutions are just active-x, applet, drawing on a texture, etc. - buggy, inefficient, low access, high cpu, etc. Scaleform's actually suppose to be based on the work made by Gameswf though (like Gnash). Which was a nice start. There's a few forks but nothing substantial that I know of. I'm just anxious. :D
Okay, great! Well here is a question then!
Like, in short, will I be able to write stuff with flex that interacts with js in a sane way, or not?
I have a lot of experience working with Scaleform and overall it's not bad as long as you use it correctly. That really is about all I can say about it in a public forum.
But back on topic AS is certainly object oriented but Adobe's decision on how the stage and timeline are to be used feels a bit more like 'C' in AS instead of 'C++' in AS. AS 3.0 is certainly much better than 2.0 and 2.2 but it still has its fair share of issues. I've been to training both for Flash/AS and Flex and while they are good I must say that Adobe is insistent on doing things specifically their way instead of a common way both in their language design and UI/App design. In the end all it does is make their products harder to use since they do not follow any known UI patterns and often common object oriented language patterns. One thing that is very odd is the event system and gets even more bizarre when you attempt to pass an event to a movie clip yet receive the message at the level of a movie clip. One would think the clip would be self-aware but you actually must pass the clip in to the clip in order for the event to work. Also it is a bit odd how sprites are dealt with and does not lend itself well to any type of normal 2D sprite game development. What it ends up becoming is 'this is how you do it in Flash' and 'this is how you would do it without Flash'. It's almost the same as learning GDI graphics - the knowledge you gain is very specific to how GDI does things and not at all how the rest of the world does them. As such this creates a void in which Flash programmers feel that they can program a 2D game yet they fail to realize they can only code it inside of Flash b/c the principles they are using just do not apply outside of Flash and in pure C++ via OGL or D3D simply will not work.
Adobe Flash CS4 also tends to crash quite a bit and the debugger for AS is horrendous. It was much better, IMO, in Adobe Flash CS3.