To cast a type in ActionScript you use this
syntax:
tmpDoctor =
samples.Doctor(event.result);
(i.e. it is not the same syntax as
Java).
Also, in your Java class, note it must have a public
no-args constructor and the fields (or bean getter/setters) must be
public.
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of aejaz_98
Sent: Thursday, April 27, 2006 9:32 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Data Mapping problem
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 me! thod 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 remot! e 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
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.