--- In flexcoders@yahoogroups.com, Curtis Barrett <curtis.barr...@...> wrote: > > Right now I'm playing around with the RemoteClass feature with a few > ActionScript classes. What I've noticed is that if I have a single object I > can nest AS classes. So if I have two AS classes foo and bar I can have the > following work > > [RemoteClass(alias="com.ca.foo.Foo")] > public class foo > { > public var ID:int; > public something:bar; > } > > this gets converted correctly when I call a function that returns a foo. > bar is correctly identified as a bar and is placed as such. > > > Now here's where I've run into trouble. If I try to have an array of bars I > can't figure out how to get this to work correctly. Example: > [RemoteClass(alias="com.ca.foo.Foo")] > public class foo > { > public var ID:int > [ArrayElementType("MenuItemSetting")] > public something:ArrayCollection; > } > > This does not work. When I return from the remoteObject call foo is done > correctly up to the ArrayCollection. The ArrayCollection has objects in it > instead of MenuItemSettings. > > Here is the result function that has objects for the ArrayCollection Items > > public function Success(event:ResultEvent):void > { > var test:foo; > > if(event.result != null) > { > test = MenuItemPackage(event.result); > } > } > > However, here's where it utterly baffles me. In my result function if I add > this one line of code to it, the objects for all items in the collection > become type bar. > > public function Success(event:ResultEvent):void > { > var test:foo; > > bar(event.result.something[0]); > > if(event.result != null) > { > test = foo(event.result); > } > } > > > I do realize this will have issues if there are no elements in the > ArrayCollection or if the result is null. What the heck is happing here? I > can even put the breakpoint in before the bar(event.result.something [0]); > and look at result and it is typed to the bar. > > My other question is, can this be done automatically? Or do I need to leave > in the bar(event.result.something[0]);? >
I'd be inclined to guess that the only hard reference to bar in the class that calls the service is that one line where you call bar(event.result.something[0]); Try doing this: private var dummy:bar; And see if that fixes the problem http://flexdiary.blogspot.com/2008/11/thoughts-on-remoting.html HTH; Amy