Why wouldn't a flex remoteobject be able to work within a custom component?

Please enlighten this flex noob. I have a remoteobject within my main.mxml. I can call a function on the service from an init() function on my main.mxml, and my java debugger triggers a breakpoint. When I move the remoteobject declaration and function call into a custom component (that is declared within main.mxml), the remote function on java-side no longer gets called, no breakpoints triggered, no errors, silence.

How could this be? No spelling errors, or anything like that. What can I do to figure it out?

mxml code:

&#060 mx:RemoteObject id="myService" destination="remoteService" endpoint="${Application.application.home}/messagebroker/amf" &#062 &#060 /mx:RemoteObject &#062

function call is just 'myService.getlist();'

when I move it to a custom component, I import mx.core.Application; so the compiler doesn't yell

my child component: child.mxml

<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" >
    <mx:Script>
        <![CDATA[
            import mx.core.Application;
            public function init():void {
                helloWorld.sayHello();
            }
        ]]>
    </mx:Script>

    <mx:RemoteObject id="helloWorld" destination="helloService" endpoint="$(Application.application.home}/messagebroker/amf" />

    <mx:Label text="{helloWorld.sayHello.lastResult}" />
</mx:Panel>

my main.mxml:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" xmlns:test="main.flex.*" >
    <mx:Script>
        <![CDATA[
            [Bindable]
            public var home:String;
            [Bindable]
            public var uName:String;
            public function init():void {
                //passed in by wrapper html
                home = Application.application.parameters.appHome;
                uName = Application.application.parameters.uName;
            }
        ]]>
    </mx:Script>
    <test:child />
</mx:Application>

Answers


The child components are calling creationComplete before the parent (so home is null). A solution is to throw an event (like InitDataCompleted) from the parent after you read the data, and in the child components listen for this event (so don't rely on creationcomplete in the child).

However more important than that is how can you diagnose in future this kind of problems. A simple tool like a proxy (eg Charles) should help.


For your endpoint value you've got

endpoint="$(Application.application.home}/messagebroker/amf"

Why are you using $( before Application.application... This should be a { as in:

endpoint="{Application.application.home}/messagebroker/amf"

Need Your Help

SWIFT: UIImageView Photo Going Past Boundaries

swift uiimageview uiimage

Can anybody tell me why my photos go beyond the boundary of UIImageView?

Create a heatmap using Yii2 highcharts widget

highcharts yii2 heatmap

I am trying to adapt a highcharts heatmap from raw coding to the Yii2 plugin by Milos Schuman. Area and line charts are working but there is not an example of using heatmap and I tried almost every...