Did you specify RemoteClass for MenuItemPackage?
From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf
Of Curtis Barrett
Sent: Friday, January 30, 2009 7:39 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] [flexcoder] RemoteClass + ArrayCollection question
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]);?
Thanks for the help.