Hi,

One difference between Royale and Flex is that Royale cannot detect types with 
different access methods at runtime, so you will have to modify your code 
slightly to tell the compiler how to generate the access code.

IOW:  if you write:

remoteObject.GetVersion.addEventListener("result",GetVersionHandler);

Then in Flash, each access (get the property “GetVersion” from “remoteObject”, 
get the function “addEventListener” from “GetVersion”) is handled by Flash and 
it knows that remoteObject is a property so it can call “getProperty” and then 
the runtime examines that, determines it is an Operation and then knows to its 
call “addEventListener”.

In Royale, the JavaScript runtimes don’t know about Proxy (at least in this 
version of Royale).  The compiler knows that remoteObject is a Proxy so it 
calls getProperty, but compiler cannot know the result is an Operation at 
compile time and the JS runtime doesn’t care anyway, so Royale’s compiler 
currently assumes that the result of a getProperty is another Proxy because 
there might be nested trees of ObjectProxys in data structures.

So, the answer is to modify the code to indicate to the compiler what the 
result of the getProperty is:

(remoteObject.GetVersion as 
Operation).addEventListener("result",GetVersionHandler);

You may need to import mx.rpc.remoting.Operation;

HTH,
-Alex

From: Maria Jose Esteve <[email protected]>
Reply-To: "[email protected]" <[email protected]>
Date: Wednesday, September 25, 2019 at 10:22 AM
To: "[email protected]" <[email protected]>
Subject: RemoteObject y addEventListener SyntaxError

[cid:[email protected]]
Hello,
I am migrating a wrapper between my app. flex and the backend (AMF - FluorineFX 
- .net). (Apache Flex - works ok)
I cannot add the listener of the result of any method. I compile well but when 
I run it gives me an error.

This is the wrapper ...

package flexfx.wpl
    {
    ...
    import mx.collections.ArrayCollection;
    import mx.core.FlexGlobals;
    import mx.messaging.Channel;
    import mx.messaging.ChannelSet;
    import mx.messaging.channels.AMFChannel;
    import mx.messaging.channels.SecureAMFChannel;
    import mx.messaging.config.ServerConfig;
    import mx.rpc.AsyncToken;
    import mx.rpc.IResponder;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;

    import flexfx.wpl.wplNetPrModel;
    import flexfx.wpl.vo.CTypeUser;
    import flexfx.wpl.voPres.CTypeModelVecIni;
    import flexfx.wpl.voPres.CTypeParNotiPres;

    public class wplNetPr
    {
      private var remoteObject:RemoteObject;
               [Bindable]public var model:wplNetPrModel;
               private var Glb:GlobalVars=GlobalVars.getInstance()
               private var Gnr:General = General.getInstance();
                    ...
      public function wplNetPr( modelo:wplNetPrModel = null )
      {
                           var channelSet:ChannelSet = new ChannelSet();
                           var channel:Channel;

                           if (modelo.isSecure){
                                  modelo.destination = "fluorineSecure";
                                  channel = new 
SecureAMFChannel(null,"Gateway.aspx");
                           }else{
                                  modelo.destination = "fluorine";
                                  channel = new AMFChannel(null,"Gateway.aspx");
                           }

                           channelSet.addChannel(channel);
                           remoteObject  = new RemoteObject(modelo.destination);
                           remoteObject.requestTimeout = -1;
                           remoteObject.showBusyCursor = true;
                           remoteObject.source = "flexfx.wpl.wplNet";
                           remoteObject.channelSet = channelSet;

                           this.model = modelo
  [ERROR]       
remoteObject.GetVersion.addEventListener("result",GetVersionHandler);
                           
remoteObject.inicializar.addEventListener("result",inicializarHandler);
                           remoteObject.addEventListener("fault", onFault);
…

SyntaxError: Unexpected token ';'
TypeError: this.flexfx_wpl_wplNetPr_remoteObject.getProperty(...).callProperty 
is not a function
    at new flexfx.wpl.wplNetPr 
(h:\Proyectos\TestFluorine\src\main\royale\flexfx\wpl\wplNetPr.as:67:29)
    at AppWPNet.AppWPNet_AppComplet 
(h:\Proyectos\TestFluorine\src\main\royale\AppWPNet.mxml:54:14)
    at AppWPNet.$EH1 
(h:\Proyectos\TestFluorine\src\main\royale\AppWPNet.mxml:7:28)
    at AppWPNet.goog.events.EventTarget.fireListeners 
(h:\Proyectos\TestFluorine\bin\js-debug\library\closure\goog\events\eventtarget.js:284:24)
    at Function.goog.events.EventTarget.dispatchEventInternal_ 
(h:\Proyectos\TestFluorine\bin\js-debug\library\closure\goog\events\eventtarget.js:381:27)
    at AppWPNet.goog.events.EventTarget.dispatchEvent 
(h:\Proyectos\TestFluorine\bin\js-debug\library\closure\goog\events\eventtarget.js:196:35)
    at AppWPNet.org.apache.royale.events.EventDispatcher.dispatchEvent 
(h:\Proyectos\TestFluorine\bin\js-debug\org\apache\royale\events\EventDispatcher.js:71:80)
    at AppWPNet.org.apache.royale.core.HTMLElementWrapper.dispatchEvent 
(h:\Proyectos\TestFluorine\bin\js-debug\org\apache\royale\core\HTMLElementWrapper.js:245:81)
    at AppWPNet.org.apache.royale.jewel.Application.initialize 
(h:\Proyectos\TestFluorine\bin\js-debug\org\apache\royale\jewel\Application.js:304:9)
    at AppWPNet.org.apache.royale.jewel.Application.start 
(h:\Proyectos\TestFluorine\bin\js-debug\org\apache\royale\jewel\Application.js:264:11)
…

I have no idea what happens, can you give me a hand?
Thank you.

M.José

Reply via email to