You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by flex capacitor <fl...@gmail.com> on 2016/12/20 14:34:23 UTC

Converting JavaScript libraries to AS3

There's a few large libraries out there that are written in JavaScript.
I've been working with them and am disappointed it's not AS3 for obvious
reasons. Since the community has been working on cross compiling AS3 to JS
is there any work on taking a JavaScript library and parsing it into a AS3
class? I'm not talking about creating a swc that you drop in and then you
have code completion in Flash Builder (I think this is externs?). I'm
talking about taking a github library or source and parsing it into AS3
classes.

Even if we may eventually cross compile that AS3 library back to JS I'd
rather import the JS library, and then work with that AS3 version of it.

Also, we as a community are catering to the JS community by converting AS3
down to JS. Can we rather convince developers to write their libraries in
AS3 from now? I mean is that already possible (it's early morning here hope
this makes sense)? I know we are working on frameworks like FlexJS but I'm
talking about addressing the thousands of libraries written in JS. My
thought on that is, along with everything else we're doing and all the
progress we've made over the years, if it's already possible to convert AS3
to JS would making Flash Builder free draw JS developers to use AS3 for
their libraries going forward?

PS Sick and tired of catering to JS from 1995

Re: Converting JavaScript libraries to AS3

Posted by Alex Harui <ah...@adobe.com>.
On 12/20/16, 6:56 AM, "Christofer Dutz" <ch...@c-ware.de> wrote:

>Hi,
>
>I think this is what our „externs“ do ... you sort of generate a no-op AS
>counterpart which the IDE is able to use for content assist, but the
>FlexJS then directly calls the JS library.
>But I bet the others will be able to give you more detailled infos on
>this.

Our ExternC tool is capable of converting the Google Externs pattern of JS
to AS.  It cannot currently handle a full JS implementation, but probably
could with a chunk of work.  But even that would only be for what I would
call prototype-based JS patterns with Google-style JSDoc.

Plenty of libraries are written with other patterns like functions that
generate the classes and use different annotations for type information.
CreateJS and Jquery for example, can't currently be parsed by ExternC.
Doing so would be a significant amount of work, IMO.  But volunteers are
welcome to try.

I believe anyone could now write a JS library in AS and cross-compile it.
I'm sure there are still transpilar bugs that need fixing though.  But
folks may not like the output format we currently support so new emitters
would need to be written.  And some folks simply like doing
non-object-oriented, non-sealed-class tricks that JS allows that AS
wouldn't in order to get performance or size.

Evangelizing our transpilar is welcome.  Keep in mind that Javascript is
not really a 1995 thing any more.  The ES5 and ES6 flavors are slowly
pushing it into a more structured feel, not unlike AS2 to AS3.

-Alex


Re: Converting JavaScript libraries to AS3

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi,

I think this is what our „externs“ do ... you sort of generate a no-op AS counterpart which the IDE is able to use for content assist, but the FlexJS then directly calls the JS library.
But I bet the others will be able to give you more detailled infos on this.

Chris

Am 20.12.16, 15:34 schrieb "flex capacitor" <fl...@gmail.com>:

    There's a few large libraries out there that are written in JavaScript.
    I've been working with them and am disappointed it's not AS3 for obvious
    reasons. Since the community has been working on cross compiling AS3 to JS
    is there any work on taking a JavaScript library and parsing it into a AS3
    class? I'm not talking about creating a swc that you drop in and then you
    have code completion in Flash Builder (I think this is externs?). I'm
    talking about taking a github library or source and parsing it into AS3
    classes.
    
    Even if we may eventually cross compile that AS3 library back to JS I'd
    rather import the JS library, and then work with that AS3 version of it.
    
    Also, we as a community are catering to the JS community by converting AS3
    down to JS. Can we rather convince developers to write their libraries in
    AS3 from now? I mean is that already possible (it's early morning here hope
    this makes sense)? I know we are working on frameworks like FlexJS but I'm
    talking about addressing the thousands of libraries written in JS. My
    thought on that is, along with everything else we're doing and all the
    progress we've made over the years, if it's already possible to convert AS3
    to JS would making Flash Builder free draw JS developers to use AS3 for
    their libraries going forward?
    
    PS Sick and tired of catering to JS from 1995