| « Thanks for the Cake! | London Flash Platform Usergroup Meeting July » |
I was just asked by a friend, "if code on the timeline in Flash 8 is no different from AS1 because it isn't inside a class file [therefore not type-checked or anything else that typically differentiates AS2 from AS1], what is AS3 code on the timeline in Flash 9?".
I didn't have a simple answer. That code will still be runtime checked etc, it certainly isn't AS1 or AS2. The reason we can't define what it is exactly is probably due to the nature of the language.
ActionScript has class structures, but they aren't the same behind the scenes as classes in what we call traditional class based languages, they are actually collections of "traits" and "property attributes" on an object prototype. If those terms are new to you, you might find the following paper of interest.
I found this paper quite some time ago probably through MXNA, and it has stuck in my mind since I first read it, it gave me a much better understanding of how a prototype language is very different to anything else, and how that makes it very suitable for GUIs which is the subject of the article.
It's a bit old, but 100% worth the read.
http://waltersmith.us/wp-content/uploads/2005/12/OOPSLA95.pdf
That paper doesn't really get technical enough, but there's a lot more info on this matter in the LiveDocs which directly related to ActionScript. The pages in that particular LiveDoc are really good reading if you like to look behind the curtain.
8 comments
Comments are closed for this post.
Follow me on Twitter
Actionscript grew in that direction, afaik, from the way earlier developers approached it.
Cheers,
Emmanuel
Really, I find it interesting that AS3 looks so much like Java, but works in a very different way, and that makes it harder to predict in certain situations, but also more flexible in others!
"If you do not associate a timeline with a class, one is automatically created for that timeline by Flash. When this happens, variables become class variables, all named functions (declared using function functionName(){}) become methods of that class, and all scripts within the frames associated with methods that are automatically called when that frame is reached (minus the variable and method definitions)."
http://www.kirupa.com/forum/showthread.php?p=1914661#post1914661
Hope this helps
Osc23
http://www.kirupa.com/forum/showthread.php?t=223798
Sorry for posting twice ;)
Osc23
The tips Osc23 posted also go to explain the use of the prototype object in AS3 - where though it is not the primary means of inheritance, it still exists in AS3 (mirroring the inheritance chain of the class) and can still be used to assign members to a class dynamically as you could in AS1 and AS2.
something that opened my eyes to the subject "class based vs. prototype":
http://www.zwetan.com/blog/ECMAScript/RaisingHell.html
it is also advisable to simply read the ecma-specs or the "prototype based languages"-pdf (linked from zwetan's post).
although it seems something changed in the as3-prototype implementation regarding inheritance. don't know exactly but got burrned by tink once about this subject ;)
hope it's useful
-sh
Yeah I remember they changed the way inheritance and prototype lookups work. Again thanks for the link, keep them coming! :)