Hi,

I have a an ActionScript class Doctor.as as follows,

package samples
{
 [Bindable]
 [RemoteClass(alias="samples.ht.base.Doctor")]
 dynamic public class Doctor
 {
   public var firstName:String;
   public var lastName:String;
   public var phoneNumber:String;
 }
}

The corresponding Java class Doctor.java is,

package samples.ht.base ;

public class Doctor {
    String firstName;
    String lastName;
    String phoneNumber;

    public Doctor(String fname, String lname, String phoneNum){
        firstName = fname;
        lastName = lname;
        phoneNumber = phoneNum;
    }
}

I make a RemoteObject method call which returns a Doctor. In my method which handles the result, I have,

        [Bindable]
        public var tmpDoctor:Doctor ;
       
        private function getNameHandler(event:ResultEvent):void
        {
            tmpDoctor = (samples.Doctor)event.result ;
             ......


If I don't have the dynamic keyword in Doctor.as, I get an Exception from Flash which says,
ReferenceError: Error #1056: Cannot create property _phone_number on samples.Doctor

Reading about Error 1056 implied that I had to make the Doctor class(in Actionscript) dynamic.  What is happening now is that, I am getting control in getNameHandler method after the remote method is executed but after the line in blue is executed, tmpDoctor is null. By looking at event.result from the debugger I can see the following,

result = samples.Doctor (@550cb26)
    firstName = null
    _firstName = "Michael"
    lastName = null
    _lastName = "Schumacher"
    phoneNumber = null
    _phone_number = "100"

Why is casting not working properly ? I had expected that tmpDoctor would have its fields properly populated. Why is that not happening & what is the way to access the results returned in the fields starting with underscores ? I am sorry in advance as I have just started learning Actionscript.

Thanks,
Aejaz



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to