flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Newman <Capta...@unFocus.com>
Subject Re: [FalconJS] concepts
Date Thu, 29 Nov 2012 00:03:27 GMT
On 11/28/12 4:42 PM, Alex Harui wrote:
> I don't know enough to have an reason not to go the classic route.  But
> someone else will have to step up to do the work.
Classic is the fastest for me (often by a lot) - at least in Firefox. 
Maybe I'm missing some reason to go with the others?

> That said, because we are cross compiling AS, does the classic route support
> as many features of AS, especially the reflection-oriented features?  We
> want to try to compile business logic untouched and it might be using "is",
> "in", "instanceof", etc.  Resig's blog seems to indicate that support for
> instanceOf was important and required all of that code.

I don't think you need all that code, you can do this:

function BaseClass( yourVal ) {
     this.someVal = yourVal;
BaseClass.prototype = {
     myMethod: function() {
         console.log( this.someVal );

function Extended( yourVal ) {
     // super
     BaseClass.apply( this, arguments );

     this.someOtherVal = yourVal + " other";
Extended.prototype = Object.create( BaseClass.prototype ); // avoids 
calling parent
Extended.prototype.myExtendedMethod = function() {
     console.log( this.someOtherVal );
// override
Extended.prototype.myMethod = function() {
     // super
     BaseClass.prototype.myMethod.apply( this, arguments);

var ext = new Extended( "test" );
ext.myMethod(); // test
ext.myExtendedMethod(); // test other

ext instanceof BaseClass; // true
ext instanceof Extended; // true

Object.create is native in modern browsers, and has a simple polyfill 
(for the relevant portions) for IE.

Part of what John Resig was trying to do was to create editable and 
writable classical inheritance from working within JS. FalconJS doesn't 
have this constraint. We don't need to edit the generated Javascript 
since the next AS3 compile would wipe out any changes anyway? Better to 
make it fast (and besides, that's still readable, and you even could 
edit it if you wanted).

Kevin N.

View raw message