Actionscript

Flex Remoting ignores class mapping

if your application does not yet actually use that client Class.  In my application, the result of a remote invocation kept returning a dynamic Object instead of the intended ValueObject class “Slot” although I specified the mapping and the RemoteClass metadata:

weborb-config.xml

   <classMapping>
     <clientClass>com.cae.planning.models.Slot</clientClass>
     <serverClass>Slot</serverClass>
     <source>Slot</source>
   </classMapping>

Slot.as

    [Bindable]
    [RemoteClass(alias="com.cae.planning.models.Slot")]
    public class Slot { ... }

So merely including the “import com.cae.planning.models.Slot;” in my application does not instruct the compiler to actually include that Class and therefore knows about the class mapping. Obviously, this can only happen if you work on new client classes that you are not yet using anywhere in your application.

Tiny, single-purpose class: ResultToFunctionAdaptor

Every now and then I need a small piece of functionality that perfectly fits into a single, minimal-behavior thus single-purpose class. This time I am developping a Adobe Flex application that uses the RemoteObject facilities. Before invoking a method on a RemoteObject, you have to add two event handlers that will be called with a ResultEvent or a FaultEvent respectively. Typically in the “onResult(event:ResultEvent)” function, one takes the result of the event and calls another function or update a view.

Sorting XMLListCollection by attribute

Just want to share the result of a small puzzle I had about sorting elements of an XMLListCollection by one of the attributes of such an element. At first, I tried sorting the elements of the XMLList I had, but the API does not provide any methods to do that. Bruce Phillips wrote a snippet that pointed me to right direction. So, here it is:

var doc:XML = <root>
      <item name="C"/>
      <item name="B"/>
      <item name="A"/>
  </root>
var collection:XMLListCollection = doc.item
var sort:Sort = new Sort()
sort.fields = [ new SortField("@name", true) ]
collection.sort = sort
collection.refresh()

As expected, the collection will show: