royale-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Library SWC (library path)
Date Wed, 26 Sep 2018 19:07:39 GMT
Hi Fréderic,

Regarding reusing existing libraries:  I think it depends on how much Flash dependencies there
are.  You can run an API report as Piotr suggested or if you don’t have too many mxml files
in the SWC, you can scan the AS and MXML files for “import flash” and get an idea of what
Flash classes were used.  MXML automatically imports a bunch of Flash classes so you miss
some in MXML files.

One of the reasons I suggested picking a runtime environment first is because it has impact
on how you implement certain features.  For example, if you are using the AIR File class,
but are going to load the Royale JS files into a WebView, you might want to write your own
File class for Royale that talks across the WebView/AIR boundary right to the AIR File class.
 Then you won’t need to change as much of your code.

HTH,
-Alex

From: Fréderic Cox <coxfrederic@gmail.com>
Reply-To: "users@royale.apache.org" <users@royale.apache.org>
Date: Wednesday, September 26, 2018 at 11:47 AM
To: "users@royale.apache.org" <users@royale.apache.org>
Subject: Re: Library SWC (library path)

Hi Alex,

Thanks for your careful and complete answers, much appreciated!
Your reply makes it 100% clear for me that I can not use the existing libraries and need to
rewrite most code. So I will create duplicates from scratch meaning I will keep same structure
of classes like before but I will create the SWC using a library project in Royale. Then I
will copy the code that is not Flash or AIR dependant.

For example I have a ServerUtil class which I can re-use, except for storing the value of
the server location which is dependant on the File class. So my question here is, can I use
the WebStorage API for that? Can I write that in JS or do I need to create a AS3 equivalent
that is transpiled to JS?

On Wed, Sep 26, 2018 at 5:43 PM Alex Harui <aharui@adobe.com<mailto:aharui@adobe.com>>
wrote:
Hi Fréderic,

Just to be clear, the main goal of Royale is to provide a Flex-like application development
workflow, but not to be 100% backward compatible with Flex.  Flex itself was an attempt to
abstract away the intricacies of Flash and similarly, Royale is not focused at all on providing
Flash APIs.

So, the migration of a Flex app to Royale involves either using the Emulation components as
much as possible (still a work in progress) or rewriting the UI to use Royale component sets
like Jewel.  Where your application has a direct dependency on Flash, that code will definitely
need to be changed.  But if you have good separation of concerns between your UI and your
business logic, you should find that your business logic should be almost 100% re-usable.
 And that last sentence is why Royale should be a lower-effort way to get off of Flash/AIR
than rewriting and debugging your business logic.

So, if your app has custom SWCs containing source code written by you, the SWC should be re-usable
in Royale if it isn’t dependent on Flash.  If there are Flash dependencies, you will need
to tweak the code to remove the Flash dependency.  The error about BitmapAsset is probably
because there are embedded assets.  Royale does not support embedding of graphical assets
at this time.  Not sure if we will in the short term as it isn’t clear there is a significant
technical advantage to embedding like there was in Flash.

A Flex SWC cannot be used “as-is” since all Royale SWCs must contains transpiled JS files
from the source AS files.  So you must re-compile all of your SWCs with the Royale Compiler.
 And fix any issues around Flash dependencies and workaround any Flex dependencies we haven’t
supported yet in Royale.

I have not used VSCode myself, but you’ll have to set up library projects for each of your
SWCs, get them to compile cleanly, and then try compiling the main app.

I’ve been migrating TourDeFlex to Royale.   I found that there were a couple of common embedding
patterns.  One was “inline-MXML” as in:

  <mx:Image source=”@Embed(‘assets/foo.png’)” />

I just removed the embedding for now:

  <mx:Image source=”assets/foo.png” />

The other common pattern was in AS such as:

  [Embed(“assets/foo.png”)]
  var fooPNG:Class;

I think all instances I found were being assigned as the source for an Image component, so
it was simple enough to transform that to:

   var fooPNG:String = “assets/foo.png”;

I thought about trying to get the compiler to auto-convert these patterns, but I’m not sure
it would be worth the effort.

Anyway, try to set up your library projects and remove Flash dependencies and eventually it
should all compile and start to run without Flash.  I’m sure you’ll have lots more questions.
 Don’t be afraid to ask.

HTH,
-Alex

From: Piotr Zarzycki <piotrzarzycki21@gmail.com<mailto:piotrzarzycki21@gmail.com>>
Reply-To: "users@royale.apache.org<mailto:users@royale.apache.org>" <users@royale.apache.org<mailto:users@royale.apache.org>>
Date: Wednesday, September 26, 2018 at 6:48 AM
To: "users@royale.apache.org<mailto:users@royale.apache.org>" <users@royale.apache.org<mailto:users@royale.apache.org>>
Subject: Re: Library SWC (library path)

I don't think so - at least if you would like to transpile your code to JS. That's good that
you are getting this kind of errors. It means that probably compiler is trying to transpile
and cannot pass some code. I believe you have two paths:

1) Rewrite your UI part of app to Royale and transpile AS3 code
2) You can use Emulation components [1] to make proper build of your app with transpilation
to JS. - From that point you could slowly make UI looks better.

I bet that no one tried to Emulate FileStream yet! :) If something doesn't exists here [2][3]
you probably can add it to make your app satisfied.

You can generate API report (here instruction [1]) to see what actually you are using in your
app, look on the list in [2][3] and fill gaps by making pull requests.

[1] https://github.com/apache/royale-asjs/wiki/emulation-components<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Froyale-asjs%2Fwiki%2Femulation-components&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562346359&sdata=0cUnkh2SZebQ7ziToHQ3fUxH6DW58066E3wPclWfaj8%3D&reserved=0>
[2] https://github.com/apache/royale-asjs/blob/develop/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Froyale-asjs%2Fblob%2Fdevelop%2Fframeworks%2Fprojects%2FMXRoyale%2Fsrc%2Fmain%2Froyale%2FMXRoyaleClasses.as&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562356364&sdata=%2BOay5OTO7B7vYmLezCpEYW9rfS7VhjKPTggoPmhXCmQ%3D&reserved=0>
[3] https://github.com/apache/royale-asjs/blob/develop/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Froyale-asjs%2Fblob%2Fdevelop%2Fframeworks%2Fprojects%2FSparkRoyale%2Fsrc%2Fmain%2Froyale%2FSparkRoyaleClasses.as&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562356364&sdata=ir1COf7Ok1wq7X6H9i3ZdwcnDOdJjtO3sL%2FsraZBAws%3D&reserved=0>

Thanks,
Piotr

śr., 26 wrz 2018 o 15:39 Fréderic Cox <coxfrederic@gmail.com<mailto:coxfrederic@gmail.com>>
napisał(a):
If I do it with source-path I'm getting around 3K errors like "The definition of base class
BitmapAsset was not found or Call to a possibly undefined method FileStream etc... so I think
that answers your last question :-)

I was expecting to be able to use the existing Flex SWC's, is this not possible?

On Wed, Sep 26, 2018 at 3:33 PM Piotr Zarzycki <piotrzarzycki21@gmail.com<mailto:piotrzarzycki21@gmail.com>>
wrote:
This is probably why it's not working. I'm not an expert in that, but first what I would tried
is create Royale library. However instead linking library, can you link source code ?
"source-path": [
"src",
"mylibrary/src"
],

Is this pure AS3 code without dependency to Flash ?

Thanks,
Piotr

śr., 26 wrz 2018 o 15:21 Fréderic Cox <coxfrederic@gmail.com<mailto:coxfrederic@gmail.com>>
napisał(a):
I tried external-library-path but if I do not use js-library-path I get compile errors "Access
of possibly undefined property .."

EnalityFlexLibrary is an existing Flex library.

On Wed, Sep 26, 2018 at 2:57 PM Piotr Zarzycki <piotrzarzycki21@gmail.com<mailto:piotrzarzycki21@gmail.com>>
wrote:
Hi Frederic,

Have you tried external-library-path ? There is some explanation how js-library-path working
[1]. However EnalityFlexLibrary is a Flex library or did you create Royale swc ?

[1] http://apache-royale-development.20373.n8.nabble.com/Difficulties-with-using-in-project-JS-version-of-Royale-swc-tp5999p6015.html<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-royale-development.20373.n8.nabble.com%2FDifficulties-with-using-in-project-JS-version-of-Royale-swc-tp5999p6015.html&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562366374&sdata=rDYyUGRnlVo%2FBZYGkwg3Vw08%2BrbV1cl1GVBGXKcyZls%3D&reserved=0>

Thanks,
Piotr

śr., 26 wrz 2018 o 14:49 Fréderic Cox <coxfrederic@gmail.com<mailto:coxfrederic@gmail.com>>
napisał(a):
Can anyone help me on this? Why is this not working? The path to the SWC is correct.

<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fns.adobe.com%2Fmxml%2F2009&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562366374&sdata=%2BXI%2FUaUE8jotJrDXtI%2Fu33zcPS5gV86Qu21LaylReg0%3D&reserved=0>"
xmlns:js="library://ns.apache.org/royale/express<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fns.apache.org%2Froyale%2Fexpress&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562376383&sdata=GleixZvCV2DH4oP19SiHPRYIjj4nzb9MBZWzQPZIQMw%3D&reserved=0>"
applicationComplete="applicationCompleteHandler(event)">

<fx:Script>
<![CDATA[
import org.apache.royale.events.Event;
import com.enality.utils.ServerUtil;
// import com.enality.EnalityData;

private function applicationCompleteHandler(evt:Event):void{
// alert(EnalityData.rootURL);
ServerUtil.setServerSettings();
// alert(EnalityData.rootURL);
}
]]>
</fx:Script>

<js:initialView>
<js:View>
<js:Label text="Hello EnalityCMS!" x="100" y="100" />
</js:View>
</js:initialView>

</js:Application>

{
"compilerOptions": {
"source-map": true,
"targets": [
"JSRoyale"
],
"js-library-path": [
"/Users/frederic/Desktop/Exuvis/CityFashion/EnalityFlexLibrary/bin/EnalityFlexLibrary.swc"
],
"library-path": [
"/Users/frederic/Desktop/Exuvis/CityFashion/EnalityFlexLibrary/bin/EnalityFlexLibrary.swc"
],
"html-output-filename": "index.html"
},
"files": [
"src/EnalityCMS.mxml"
]
}

Error I'm getting =

using SWC: /Users/frederic/Desktop/Exuvis/CityFashion/EnalityFlexLibrary/bin/EnalityFlexLibrary.swc
Could not find file for class: com.enality.utils.ServerUtil
Error: File not found: com.enality.utils.ServerUtil

On Wed, Sep 26, 2018 at 2:37 PM Fréderic Cox <coxfrederic@gmail.com<mailto:coxfrederic@gmail.com>>
wrote:
However I can't seem to reference code from inside the .swc. Here is my asconfig.json file:

{
"compilerOptions": {
"source-map": true,
"targets": [
"JSRoyale"
],
"library-path": [
"/Users/frederic/Desktop/Exuvis/CityFashion/EnalityFlexLibrary/bin/EnalityFlexLibrary.swc"
],
"html-output-filename": "index.html"
},
"files": [
"src/EnalityCMS.mxml"
]
}

On Wed, Sep 26, 2018 at 12:44 PM Fréderic Cox <coxfrederic@gmail.com<mailto:coxfrederic@gmail.com>>
wrote:
OK I found it, info about this on https://github.com/BowlerHatLLC/vscode-nextgenas/wiki/asconfig.json#library-path<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FBowlerHatLLC%2Fvscode-nextgenas%2Fwiki%2Fasconfig.json%23library-path&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562376383&sdata=dyy8YwPFHUB8yfvLjUqvB39ky6a%2By07nJg8drGUXunc%3D&reserved=0>

On Wed, Sep 26, 2018 at 12:12 PM Fréderic Cox <coxfrederic@gmail.com<mailto:coxfrederic@gmail.com>>
wrote:
Hi,

I've managed to create my first Hello World app using Apache Royale. Now I'm wondering how
can I link existing .swc's? I have a bunch of library projects which have assets, .as code
files and .mxml code files. Is it possible to link those .swc files in an Apache Royale project
(I'm using VSCode)? I want to be able to use the API's from the library in my new ApacheRoyale
project so I can keep using the same libraries I used when working in Flash Builder with Flex
for AIR.

Thanks for the info!

Best regards,

Fréderic


--

Piotr Zarzycki

Patreon: https://www.patreon.com/piotrzarzycki<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.patreon.com%2Fpiotrzarzycki&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562386388&sdata=b8jXwD8nj0atVbgXR7IF0d22XSlqG3ZXoYW6Iu2wlvs%3D&reserved=0>


--

Piotr Zarzycki

Patreon: https://www.patreon.com/piotrzarzycki<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.patreon.com%2Fpiotrzarzycki&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562396397&sdata=QTaog2PYF0vsthNW9Wwsi987MIeIxxHw95v4J3GyL2M%3D&reserved=0>


--

Piotr Zarzycki

Patreon: https://www.patreon.com/piotrzarzycki<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.patreon.com%2Fpiotrzarzycki&data=02%7C01%7Caharui%40adobe.com%7Cba68686fb2fc46a66c3c08d623e08622%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636735844562396397&sdata=QTaog2PYF0vsthNW9Wwsi987MIeIxxHw95v4J3GyL2M%3D&reserved=0>
Mime
View raw message