Fred, that’s great to know that conditional compiling is working! I’ll probably take that route trying to back port and get rid of our .js files.
-Alex On 6/23/15, 9:51 PM, "Frédéric THOMAS" <webdoubl...@hotmail.com> wrote: >>> HtmlContainer.load([JQUERY_SCRIPT], init); >> >> As a > side note, this can be also used in FlexJS application (swf / swc), not > only externs JS based applications, the callback will be called >immediately, that's it. > >To make things even clearer, especially because I use conditional >compilation with 2 build configurations, I can build my library in a once >with IntelliJ. > >https://paste.apache.org/kOwX > >My AS Build Configuration: >-define+=CONFIG::AS,true >-define+=CONFIG::JS,false >-include-file=js/out/HtmlContainer.js,out\production\HtmlContainer\js\out\ >HtmlContainer.js > >My JS Build Configuration: >-define+=CONFIG::AS,false >-define+=CONFIG::JS,true >-js-output-type=FLEXJS > >Frédéric THOMAS > >---------------------------------------- >> From: webdoubl...@hotmail.com >> To: dev@flex.apache.org >> Subject: RE: [FalconJX FlexJS] JQuery up and running, a nightmare but >>we now have 1.9 in AS >> Date: Tue, 23 Jun 2015 19:55:05 +0100 >> >>> HtmlContainer.load([JQUERY_SCRIPT], init); >> >> As a side note, this can be also used in FlexJS application (swf / >>swc), not only externs JS based applications, the callback will be >>called immediately, that's it. >> >> The function as it is today is simple but could be implemented to send >>events instead of using a callback, parallel downloads, css, etc... >> >> It is not as perfect as adding a MetaTag in AS (emitted only in JS) to >>do the same job (or event better, what I was thinking, to emit directly >>the Script tag comment in the generated JS file) but it works. >> >> Frédéric THOMAS >> >> >> ---------------------------------------- >>> From: webdoubl...@hotmail.com >>> To: dev@flex.apache.org >>> Subject: RE: [FalconJX FlexJS] JQuery up and running, a nightmare but >>>we now have 1.9 in AS >>> Date: Tue, 23 Jun 2015 19:27:55 +0100 >>> >>>> It just occurred to me that you can’t use this sort of mechanism >>>>because >>>> none of the JS or AS actually gets baked into the final JS so there >>>>will >>>> never be an <inject_html> tag found by the scan. >>> >>> I know that, that's why I'm proposing other mechanisms. >>> >>> I just created a HtmlContainer.swc with the simple extern JS based >>>function I shown before to load multiple scripts, adding this lib in my >>>project, I can now use it to import the jQuery JS library or any other >>>from inside the AS code, rebuild, and it will work from the generated >>>index.html, like that: >>> >>> private static const JQUERY_SCRIPT:String = >>>'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'; >>> >>> public function start():void { >>> HtmlContainer.load([JQUERY_SCRIPT], init); >>> } >>> >>> private function init():void { >>> const button:Element = document.createElement("button"); >>> button.onclick = function ():void { >>> alert("Hello browser from FalconJX!"); >>> }; >>> button.textContent = "Say Hello"; >>> document.body.appendChild(button); >>> >>> var div:HTMLDivElement = document.createElement("DIV") as >>>HTMLDivElement; >>> >>> $(document.body).append(div).ready(function():void { >>> $(div).html("This is Hello World by JQuery"); >>> $(div).css("border", "2px solid green"); >>> $(div).insertBefore(button); >>> }); >>> } >>> >>> Frédéric THOMAS >>> >>> >>> ---------------------------------------- >>>> From: aha...@adobe.com >>>> To: dev@flex.apache.org >>>> Subject: Re: [FalconJX FlexJS] JQuery up and running, a nightmare but >>>>we now have 1.9 in AS >>>> Date: Tue, 23 Jun 2015 17:06:32 +0000 >>>> >>>> >>>> >>>> On 6/23/15, 8:53 AM, "Frédéric THOMAS" <webdoubl...@hotmail.com> >>>>wrote: >>>>> >>>>>Playing with the externs, we've seen that in order to customize our >>>>>index.html (adding a Script tag for JQuery for example) we had to >>>>>create >>>>>another index.html outside the build folder referencing our main .js >>>>>because the original one was overridden each time we built, so, >>>>>instead >>>>>of doing that, I was looking for a way to write our Script tag from AS >>>>>which is not possible at the moment and we haven't got a template >>>>>index >>>>>to use neither. >>>>> >>>>>ok, IIUC, the goal of having externs is to ease the implementation of >>>>>as/js components giving the possibility to implement them in AS and >>>>>use >>>>>the generated JS as JS source of the new FlexJS component, so, we >>>>>can, in >>>>>the generated JS, add a comment to load a JS Script or CS. >>>>> >>>>>But still, if I look at the jQuerySample.mxml, I can see something >>>>>that >>>>>should be done at each build, not every user friendly: >>>>> >>>>> >>>>>So, my goal was to simplify link and script tags either making them >>>>>accessible from the AS via a MataTag for example or having an utility >>>>>class to download dynamically those resources and add them to the >>>>>head of >>>>>the html application container. >>>>> >>>>>Am I clearer ? Did I miss something ? Is that a bad direction ? >>>> >>>> Yeah, I think I get it. Actually, that comment in JQuerySample.mxml is >>>> obsolete. The org.apache.flex.jquery.Application.js has <inject_html> >>>> tags in a comment in that file, and GoogDepsWriter.java and >>>> MXMLFlexJSPublisher.java find it and add it to the index.html. That is >>>> how FlexJS handles bootstrapping JS frameworks. >>>> >>>> It just occurred to me that you can’t use this sort of mechanism >>>>because >>>> none of the JS or AS actually gets baked into the final JS so there >>>>will >>>> never be an <inject_html> tag found by the scan. >>>> >>>> The reason it works for FlexJS is because some non-extern class like >>>> Application has to be used in the app. If you create your own Jquery >>>> Application that folks must subclass in their apps then you can use >>>>the >>>> same mechanism. Otherwise, you probably need to invent a new >>>>mechanism. >>>> >>>> One idea I considered was this: Right now in any SDK there is a >>>> flex-config.xml and an air-config.xml and often an >>>>airmobile-config.xml. >>>> These configs specify a set of libraries and other settings. We could >>>> create a js-config.xml and jquery-config.xml and figure out a way to >>>>tell >>>> the compiler in the -config.xml what to inject into the .html. Then >>>>in FB >>>> and elsewhere, you can switch by adding +configname=js or >>>> +configname=jquery just like we do +configname=air >>>> >>>> I’m sure there are other ways as well. >>>> >>>> Thoughts? >>>> -Alex >>>> >>>> >>> >> >