royale-asjs icon indicating copy to clipboard operation
royale-asjs copied to clipboard

Runtime Error When Loading Module in Flex Emulation

Open yishayw opened this issue 4 years ago • 10 comments

Consider

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="library://ns.apache.org/royale/mx" xmlns:fx="http://ns.adobe.com/mxml/2009"
		   applicationComplete="init()" xmlns:js="library://ns.apache.org/royale/basic" >
	<fx:Script>
		<![CDATA[
			private function init():void
			{
				ml.url = "Test1.swf";
			}
		]]>
	</fx:Script>
	<mx:VBox>
		<mx:ModuleLoader id="ml"/>
	</mx:VBox>
</mx:Application>

Where Test1.mxml is

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="library://ns.apache.org/royale/mx" xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:js="library://ns.apache.org/royale/basic" >
    <mx:VBox width="100%" height="100%">
        <mx:Label text="This Label is in the module" />
        <mx:TextInput id="ti" text="This TextInput is also in the module" />
    </mx:VBox>
</mx:Module>

The debug version loads the module successfully but the release version will fail in run-time with

TypeError: this.createElement is not a function

yishayw avatar Apr 27 '20 14:04 yishayw

Please also provide the compiler options used for the app and the module.

aharui avatar May 11 '20 05:05 aharui

build_example.compile-js-release: [echo] Doing release..................... [mxmlc] MXMLJSC [mxmlc] -remove-circulars [mxmlc] -js-output-optimization=skipAsCoercions [mxmlc] -js-compiler-option=--skip_type_inference [mxmlc] -targets=JSRoyale [mxmlc] -compiler.debug=false [mxmlc] +royalelib=C:\dev\flexjs\royale-asjs/frameworks/ [mxmlc] +configname=flex [mxmlc] -- [mxmlc] C:\dev\RoyaleComponentTest\NewComponentTest/src/Main.mxml

and

build_example.compile-js-release: [echo] Doing release..................... [mxmlc] MXMLJSC [mxmlc] -remove-circulars [mxmlc] -js-output-optimization=skipAsCoercions [mxmlc] -js-compiler-option=--skip_type_inference [mxmlc] -targets=JSRoyale [mxmlc] -compiler.debug=false [mxmlc] +royalelib=C:\dev\flexjs\royale-asjs/frameworks/ [mxmlc] +configname=flex [mxmlc] -- [mxmlc] C:\dev\RoyaleComponentTest\NewComponentTest/src/Test1.mxml

I have a hunch it's related to mx_internal renaming.

yishayw avatar May 11 '20 10:05 yishayw

@alinakazi , is your app using mx modules in release mode? @aharui , will you have a chance to look at this?

yishayw avatar Sep 27 '20 19:09 yishayw

Hi @yishayw, we just commented in a thread with Greg and Chris that modules has some issues. Don't think Alina used Modules or any other real app out there due to that issues. I think we need to work over that to make it work in basic, jewel and emulation.

carlosrovira avatar Sep 27 '20 20:09 carlosrovira

Hi @yishayw DBIZ Solutions had deployed debug mode for the demo purpose to client. Release mode wasn't working properly.

On Mon, 28 Sep 2020, 1:27 am Carlos Rovira, [email protected] wrote:

Hi @yishayw https://github.com/yishayw, we just commented in a thread with Greg and Chris that modules has some issues. Don't think Alina used Modules or any other real app out there due to that issues. I think we need to work over that to make it work in basic, jewel and emulation.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apache/royale-asjs/issues/814#issuecomment-699684198, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIYHTSWMPNN32TZNAPEKOULSH6N2TANCNFSM4MR7ETTA .

alinakazi avatar Sep 28 '20 08:09 alinakazi

Hello @carlosrovira, I can't make modules work on my app. Even this example given in the official documentation doesn't work for me. Do you have any news or alternative for this ? Because I have to migrate a whole app from flex to apache-royale and the main menu calls modules.

Paulitino avatar Dec 07 '20 16:12 Paulitino

Hi @Paulitino, this was commented on the dev mailing list already. I recommend you to suscribe there and stay tunned since all happens there. In resume:

  1. To make the example you mention to work you need to build using Maven. I never coded the ANT script and left for other insterested. Maven has a special processing to copy module to the main app target folder, so the running app can find and load the module

2- Modules still doesn't work as expected in release mode. This is something that need to be addressed, but the guys that can make it happen (mostly Greg or Josh) are very busy. So, if someone of you need this functionality, I recommend you to put in contact with this guys and contract some paid hours as other in the community did to make them focus on special issues we need to have solved.

In Apache there's two ways to make things happen. One is make yourself, other pay others to make it happen.

HTH

carlosrovira avatar Dec 07 '20 16:12 carlosrovira

Hi,

With Emulation, We have created a separate method that loads the royale module.

Sample is available here: https://paste.apache.org/esa6h

HTH, Alina Kazi

On Mon, 7 Dec 2020, 9:44 pm Paulitino, [email protected] wrote:

Hello @carlosrovira https://github.com/carlosrovira, I can't make modules work on my app. Even this https://royale.apache.org/dividing-an-apache-royale-application-with-modules/ example given in the official documentation doesn't work for me. Do you have any news or alternative for this ? Because I have to migrate a whole app from flex to apache-royale and the main menu calls modules.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apache/royale-asjs/issues/814#issuecomment-740037701, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIYHTSUUOO4FDE5JAPFI4SLSTUA75ANCNFSM4MR7ETTA .

alinakazi avatar Dec 07 '20 21:12 alinakazi

Hello,

First I would like to say thank you to @carlosrovira and @alinakazi for your fast responses.

I still got problems even with the sample you gave me. I have two files, one index.mxml that should load the module in module.mxml.

index.mxml:

<ex:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:j="library://ns.apache.org/royale/jewel"
                xmlns:js="library://ns.apache.org/royale/basic"
                xmlns:html="library://ns.apache.org/royale/html"
                xmlns:ex="library://ns.apache.org/royale/express"
                xmlns:mx="library://ns.apache.org/royale/mx"
                xmlns:views="modules.*"
                xmlns:ns1="components.*">

    <fx:Script>
		<![CDATA[
            import org.apache.royale.events.Event;

            private function loadForm():void {
		loadModule("modules/module",null);
            }

            public function loadModule(swfApp:String, link:String=""):void {
                mMainLoader.url = swfApp;
                mMainLoader.visible = true;
                mMainLoader.includeInLayout = true;
            }
		]]>
	</fx:Script>

    <ex:beads>
        <js:ApplicationDataBinding />
    </ex:beads>

    <ex:initialView>
        <j:View>
            <j:beads>
                <j:VerticalCenteredLayout/>
            </j:beads>

            <mx:ModuleLoader id="mMainLoader" paddingTop="0"
			 width="100%" height="100%" y="0" x="0"/>

			 <mx:Button label="Change Icon" click="loadForm()"/>
        </j:View>
    </ex:initialView>
</ex:Application>

module.mxml:

<j:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:j="library://ns.apache.org/royale/jewel"
        xmlns:js="library://ns.apache.org/royale/basic"
        initComplete="initModule()">

    <fx:Script>
        <![CDATA[
            private function initModule():void
            {
                trace("Initialize the module!");
            }
        ]]>
    </fx:Script>

    <j:beads>
        <js:ContainerDataBinding/>
        <j:VerticalLayout/>
    </j:beads>

    <j:HGroup gap="3">
        <j:IconTextInput>
            <j:beads>
                <j:TextPrompt prompt="Search..."/>
                <j:SizeControl size="xlarge"/>
            </j:beads>
            <j:icon>
                <js:MaterialIcon text="{MaterialIconType.SEARCH}"/>
            </j:icon>
        </j:IconTextInput>
        <j:Button text="Search" emphasis="secondary">
            <j:beads>
                <j:SizeControl size="xlarge"/>
            </j:beads>
        </j:Button>
    </j:HGroup>

</j:Module>

To build (not with Maven, I will try later on) I use the commands: mxmlc +configname=flex src/index.mxml mxmlc +configname=flex -module-output=modules src/modules/module.mxml

I have no error during the build.

The files organization is: screentreefiles

I have the error Uncaught TypeError: Cannot read property 'addElement' of undefined to the first click to the button and then Uncaught TypeError: c.za is not a function each time I click the button.

Do you have any idea or solution on these errors ?

Thank you,

Paulitino avatar Dec 08 '20 17:12 Paulitino

Any update on this? This seems critical to getting to 1.0

Laturine avatar Jun 14 '21 23:06 Laturine