0
votes

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>
2
are you able to see if the function (on the flex side) that contains the service call is getting called?asawilliams
yes, I set up alerts to pop up before and after the remoteobject service call, and they do.gtrak
do you think you could post more code?asawilliams
added code... it all works fine if I copy paste the remote object into main and run sayhello from its init(), but the point is I need the child to handle it.gtrak
Flex creation timing: help.adobe.com/en_US/Flex/4.0/UsingSDK/images/… I'll just do my initialization in initialize instead of creationComplete for now.gtrak

2 Answers

1
votes

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.

0
votes

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"