Hi,

Seeing as winter is here in NewHampshire and ice covers the ground, I used the opportunity to put my money where my mouth is;

NOTE: All the javascript is generated by code I wrote using the AST/Visitor/Walker pattern of the node hierarchy and their corresponding definitions. I have it running from the command line like MXMLC does.

I about 10 hours of programing I have the following constructs cross compiling to JS using Flacon.

I will say, Falcon is one of the best designed APIs I have used in a long time. Whoever architected this compiler gets a huge pat on the back from me.

Right now this is hoisted ontop of MXMLC as a quasi target compiler. Oh how I love prototypes. I cannot believe I actually have this working in less than two days.

As far as code, it will be in my whiteboard when it's in my whiteboard. :) Whenever that is, no specific time.

The amount of ridiculousness I felt trying to wade through the FlaconJS code prompted me to do this.

The thing I really grabbed on to is we are using the closure compiler so worrying about highly optimized cross compiler becomes a non issue. Quote Erik on this.

//-------------------------------------------------------
// ActionScript class

package com.example.components
{
        import flash.display.Sprite;
    import flash.events.Event;

    public class MyTextButton extends Sprite
    {
        public var foo:Number = 100;

        protected var baz:String = "what are you doing";

        private var _goo:String = 'goog';

        private var _bar:int = 1 + 3;

        public function MyTextButton()
        {
            super();
            testFunc(4, "20");
            for (var b:int=1;b<=10;b++) {
                bar();
            }
            for (;;) { break foo; }
            for (var g:int in blah) { r(); }
            for each (var g:Object in baz[goo]) { r(); }
            if (a) b();
            while (false) v();
            do { continue; } while (m);
            if (true) {
                if (a) {
                } else {
                    if (b == c) {
                        foo.bar['baz']['goo'].baz(42);
                    } else if (c != d) {
                    } else {
                        trace('mike');
                    }
                }
            } else if (false) {
            } else if (a < 3) {
            } else {
            }
            return a.call(i.j*k, l[m]);
        }

        public function testFunc(a:int = 4, b:String = null):Event
        {
            print();
            return null;
        }
    }
}

// end ActionScript
/////////////////////////////////////////////////////////




//-------------------------------------------------------
// Javascript class


/**
 * CROSS-COMPILED BY MXMLJxC (329449.1) ON 2012-12-09 16:07:04
 */
goog.provide('com.example.components.MyTextButton');

goog.require('flash.display.Sprite');
goog.require('flash.events.Event');

/**
 * @constructor
 * @extends {flash.display.Sprite}
 */
com.example.components.MyTextButton = function()
{
        goog.base(this);
        /**
         * @type {string}
         */
        this._goo = 'goog';
        /**
         * @type {number}
         */
        this._bar = 1 + 3;
        testFunc(4, "20");
        for(var b = 1;b <= 10;++b;){
                bar();
        }
        for(;;){
                break foo;
        }
        for(var g in blah){
                r();
        }
        for each(var g in baz[goo]){
                r();
        }
        if(a){
                b();
        }
        while(false){
                v();
        }
        do{
                continue;
        }while(m);
        if(true){
                if(a){
                }else{
                        if(b == c){
                                foo.bar['baz']['goo'].baz(42);
                        }else if(c != d){
                        }else{
                                trace('mike');
                        }
                }
        }else if(false){
        }else if(a < 3){
        }else{
        }
        m =
        return a.call(i.j * k, l[m]);
}

goog.inherits(com.example.components.MyTextButton, flash.display.Sprite);

/** @type {number} */
com.example.components.MyTextButton.prototype.foo = 100;

/** @type {string} */
com.example.components.MyTextButton.prototype.baz = "what are you doing";


/**
 * @this {com.example.components.MyTextButton}
 * @param {int} a
 * @param {String} b
 * @return {Event}
 */
com.example.components.MyTextButton.testFunc = function(a, b)
{
        print();
        return null
}

// end Javascript
/////////////////////////////////////////////////////////


Peace,
Mike

--
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com

Reply via email to