I have an ActionScript class that creates a custom Review object, like so:

///// Review.as
///// Taken from one of Adobe's online samples
package samples.restaurant
import mx.formatters.DateFormatter;

////// [RemoteClass(alias="samples.restaurant.Review")]
public class Review
    public function Review(source:Object=null)
    // some date formatting stuff happens here

    public var restaurantId:int;
    public var restaurantName:String;
    public var restaurant:Object;
    public var reviewDate:Date;
    public var reviewer:String;
    public var rating:Number;
    public var title:String;
    public var reviewText:String;
    public var email:String;



This class lets me take an ArrayCollection of generic Objects from the
server, loop through it with something like "new Review(source[i])" and get
a bunch of Review objects in an ArrayCollection. Works perfectly.

I also need to be able to write a Review object (a Java object) to the
server, so I add "[RemoteClass(alias="samples.restaurant.Review")]" above
the ActionScript class declaration. This way I can declare a "public var
review:Review", call an "addReview(review)" on my RemoteObject service, and
my server receives a Review Java object. This works perfectly too.

The problem is that once I add this "[RemoteClass(alias="...")]" line, doing
"new Review(source[i])" no longer works as expected. Given the same
ArrayCollection of generic Objects as before, "new Review(source[i])" will
still create a Review object, but now all its properties are null.

If I comment out the "[RemoteClass(alias="...")]" line I can properly cast
generic objects to Review objects again (but then I am no longer able to
send a Review Java object to the server).

Is this the way it's supposed to work? (I hope I've stated my problem
clearly.) How can I accomplish both tasks using a single Review.as class?

Thanks for any help, folks.


PS. I am using the Flex 3.5 SDK.

Reply via email to