views:

2508

answers:

1

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

+1  A: 

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
Umm.. Sorry, I forgot to mention that my RemoteObject tag was already inside fx:Declaration tag.I could do this<s:RemoteObject id="roMajorAdd" destination="MajorSrv" result="roMajorAddResult(event)" fault="Alert.show('Remote Object Error')" />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
You are using *M*ethod instead of *m*ethod. Could that be the issue?
Amarghosh
Yes, thank you. It does help..... Flash builder didn't show auto complete.
Pii