Learning Object Oriented JavaScript Programing from ActionScript

I have been doing some JavaScript / Ajax development over the past couple of weeks, and have been trying to figure out the best way to structure my JavaScript and HTML code. One thing that really surprised me when doing research is how many JavaScript projects / examples do not try to encapsulate their code (aside from within script files) or use object oriented programing. Thinking back on this, and given the evolution of JavaScript from a web scripting glue to more of an application programing language, I can understand this, but it did surprise me none-the-less.


Of course, Object Oriented programing in JavaScript can feel a little odd, especially if you are used to more traditional object oriented languages. While prototype based classes can seem weird and quirky, they do allow some amazing flexibility, as well as the use of traditional class based development.Indeed, this may be one area where long time Flash developers have an advantage when doing JavaScript development, as application development using ActionScript 1.0 requires understanding object oriented programing with JavaScript / ActionScript.Indeed, I still think that Robin Debreuil’s Building Object Oriented Apps in Flash 5 is one of the best introductions to object oriented programing in JavaScript anywhere. Chapter 12 (Objects and Classes) of Colin Moock’s ActionScript for Flash MX is also an excellent resource on object oriented programing in a prototype based language.Anyways, if you are interested in doing object oriented JavaScript development, I suggest that you also check out some of the older resources and tutorials around object oriented programing in Flash 5 / ActionScript 1.0.

8 Responses to Learning Object Oriented JavaScript Programing from ActionScript

  1. flashape says:

    Honestly, I started going that route, of getting my javscript packaged into nice little objects. Most of the time it turned out to be far more trouble than what is was worth. There were times when encapsulting functioanlity into an object made sense….but not that many. Maybe if you’re doing heavy AJAX development, it might be worth it, otherwise you might spend more time digging through classes than actually getting the work done.

  2. Daren says:

    I have also found Sam Wan and Brandon Hall’s ‘OOP with actionscript’invaluable in exploring javascript and AJAX.

  3. John Giotta says:

    After I received my Flash MX Developer Cert a few years back, I was like, “Hell lets get a JavaScript one too.”The one thing that really does through me off is the depth of a simple HTMLElement. Sometimes its a bit… I don’t want to say overwhelming, but maybe frustrating.

  4. Chris Coté says:

    I second “OOP with actionscript”… best book evar!

  5. a says:

    and what about (multiple) inheritance, access modifiers and strong typing?

  6. Paul Dale says:

    Check out MochiKit. It has much of what you’d ever want to encapsulate done for you.dojo toolkit is also in a similar vein, though I like the Mochikit abstractions better.http://www.mochikit.com

  7. rajagopal says:

    lets learn fast as early as fast

  8. Anonymous says:

    Can you guys help me out?I would like to try to become a Programer, but where do I start?