1 Reply Latest reply on Jul 21, 2008 11:32 AM by Rob Rusher

    Mapping action script object to mx:model object

      Hi all,

      I am having an action script class and an mx:model element with same elements. I want to assign an action script object to this mx:model. How can I do that one?

      Let me state it clearly.

      Say, my action script class contains two elements - user and rollno with required getter and setter methods.

      And I am having an mx:model element with the following format.

      <mx:model id="data">

      I want to assign an instance of action script class to this model object.

      I tried extending action action script class from Objectproxy and used data=actionscriptinstance.

      But it's not working properly.

      Is there anyway I can do this one?

      Thanks in advance
        • 1. Re: Mapping action script object to mx:model object
          Rob Rusher
          The quick answer:
          <mx:model id="data">
          <user>{ myASObj.user }</user>
          <rollno>{ myASObj.rollNo}</rollno>

          The bigger question might be, "Why have the mx:Model?"
          The Model tag is all Strings, so you lose data typing.
          Why not just create a value object (VO) for your user data and pass that around?
          package samples.user {
          public class User {
          public var user:String;
          public var rollNo:int;
          Then when the result data returns, cast to the VO.

          public var user:User = (eventObj.result as User)