2

I post this previously in Adobe Forum but haven't got any answers so far.

How do I do this in Flex 4?

 <mx:RemoteObject id="srv" destination="product" channelSet="{channelSet}"
 fault="faultHandler(event)">
   <mx:method name="getProducts" result="getProducts_resultHandler(event)"/>
 </mx:RemoteObject>

I got

Could not resolve <s:Method> to a component implementation.

When trying to do this

 <s:RemoteObject id="roMajor"
   destination="MajorSrv"
   fault="Alert.show('Remote Object Error')" >
     <s:Method name="AddMajor" result="roMajorResult(event)"/>
 </s:RemoteObject>

Thank you

zero323
  • 322,348
  • 103
  • 959
  • 935
Pii
  • 301
  • 4
  • 15

1 Answers1

2

Move the <RemoteObject/> tag into <fx:Declarations> tag:

<fx:Declarations>
  <s:RemoteObject id="roMajor" destination="MajorSrv" 
    fault="Alert.show('Remote Object Error')">
      <s:method name="AddMajor" result="roMajorResult(event)"/>  
  </s:RemoteObject>
</fx:Declarations>

The following is taken from RIA Zone

In Flex 4, unlike its earlier versions, non-visual children that represent new property declarations are not allowed as immediate children of an Application. You can add these non-visual children under a <fx:Declarations> tag. This includes non-visual children such as effects, validators, formatters, data declarations, and RPC classes.

So practically anything that is not displayable (that doesn't extend DisplayObject (or UIComponent to be more flex specific)), should be added to the fx:Declarations tag, not as the direct child of root tag.

Amarghosh
  • 58,710
  • 11
  • 92
  • 121
  • Umm.. Sorry, I forgot to mention that my RemoteObject tag was already inside fx:Declaration tag. I could do this but I have to create one remote object for each operation that doesn't return the same type. What I wanted to do is use one remoteObject and configure it so that different method called would invoke different functions on result event. So far I need to have one remote object for each SQL operations, it's tedious. – Pii Nov 04 '09 at 08:41
  • 1
    You are using *M*ethod instead of *m*ethod. Could that be the issue? – Amarghosh Nov 04 '09 at 10:57