I guess that can be ignored... I gave it a shot and it's working fine...
Man oh man this is some cool! Thanks again guys!
Cheers!
--LD
----- Original Message -----
From: "Luke DeWitt" <luke.dewitt@...>
To: <openamf-user@...>
Sent: Thursday, July 06, 2006 8:33 AM
Subject: Re: [Openamf-user] Mapping objects
> Very interesting and great to know!
>
> One final question and then I can leave you guys alone =D
>
> If I do that for my constructor in ActionScript, but my constructor for my
> Java class has no parameters, will I have a problem mapping objects, or
> would it work just the way it's working now?
>
> Again, thanks a ton guys, you guys have helped me so, so much!
>
> Thanks,
>
> --LD
>
> ----- Original Message -----
> From: "Todd Hivnor" <spambox_98103@...>
> To: <openamf-user@...>
> Sent: Wednesday, July 05, 2006 4:19 PM
> Subject: Re: [Openamf-user] Mapping objects
>
>
>>I think the important change here was in your constructor.
>> The following code will _not_ do what you want, I should have
>> caught it earlier.
>>
>>>> ActionScript Code for SmackletType:
>>>>
>>>> class SmackletType {
>>>>
>>>> // class properties
>>>> private var _smackletName:String;
>>>> private var _smackletTeaseLink:String;
>>>> private var _smackletLink:String;
>>>> private var _smackletThumbnail:String;
>>>>
>>>> // constructor
>>>>
>>>> public function SmackletType(smackletName:String,
>>>> smackletLink:String, smackletTeaseLink:String, smackletThumb:String) {
>>>>
>>>> _smackletThumbnail = smackletThumb; // Bad for remoting. Will null
>>>> out
>>>> smackletThumbnail
>>>> _smackletTeaseLink = smackletTeaseLink;
>>>> _smackletLink = smackletLink;
>>>> _smackletName = smackletName;
>>>>
>>>> } // SmackletType constructor
>>
>>
>> Remoting will create a SmackletType object, populate the
>> instance variables, and finally call the constructor.
>> But it won't pass any _arguments_ to the constructor.
>> So, the constructor above will actually reset
>> your instance variables like _smackletThumbnail
>> back to null, because the smackletThumb argument is null.
>>
>> If I am making an ActionScript class which is sometimes
>> instantiated via Remoting, and sometimes instantiated from
>> ActionScript code, I do something like this:
>>
>> public function SmackletType(smackletName:String,
>> smackletLink:String, smackletTeaseLink:String, smackletThumb:String) {
>>
>> if (arguments.length == 4) {
>> // Class was instantiated from ActionScript w/ all arguments
>> _smackletThumbnail = smackletThumb;
>> _smackletTeaseLink = smackletTeaseLink;
>> _smackletLink = smackletLink;
>> _smackletName = smackletName;
>> } else if (arguments.length == 0) {
>> // Class was probably instantiated via Remoting.
>> // You might test to ensure that smackletThumbnail
>> // or other instance variables are defined as expected.
>> } else {
>> // Class was called from ActionScript with wrong number of arguments.
>> // --> programmer error.
>> }
>> }
>>
>>
>>
>>
>> Luke DeWitt wrote:
>>> Hooha!
>>>
>>> It works! I am not sure whether it was removing the parameters from the
>>> constructors, removing the _ before variable names, or the fact that I
>>> moved
>>> the AS classes into a package of the same name, but it appears to be
>>> working!
>>>
>>> I couldn't get anything to work when ServiceCapture was running, and
>>> their
>>> site was down when I tried to access it, but it is working now!!
>>>
>>> Thank you both for your help... though I have a feeling I'll be back for
>>> more in the not so near future!
>>>
>>> Thanks,
>>>
>>> --LD
>>>
>>> ----- Original Message -----
>>> From: "Martin Wood" <flashdev@...>
>>> To: <openamf-user@...>
>>> Sent: Wednesday, July 05, 2006 10:27 AM
>>> Subject: Re: [Openamf-user] Mapping objects
>>>
>>>
>>>
>>>> hmm, definitely try using service capture and see what that says about
>>>> the
>>>> object being sent to flash (i think you get a 30 day trial...i bought
>>>> it
>>>> because
>>>> its an invaluable tool for remoting development)
>>>>
>>>> one other thing i noticed which you should be aware of is that the
>>>> constructor
>>>> of the actionscript class gets called after de-serialization so you
>>>> have
>>>> to be
>>>> careful what you do in your constructors.
>>>>
>>>> read this post for more information :
>>>>
>>>> http://www.darronschall.com/weblog/archives/000186.cfm
>>>>
>>>> anyway...back to the point..if you are getting a null that means that
>>>> flash cant
>>>> do that cast, so i think that the object is being sent as the correct
>>>> type
>>>> from
>>>> java.
>>>>
>>>> personally i would try these things (as well as using service capture)
>>>>
>>>> 1. Make both constructors parameter less
>>>>
>>>> 2. Remove the underscores from the properties
>>>>
>>>> 3. triple check the mapping configuration
>>>>
>>>> 4. Keep the Object.registerClass call as part of the initialization
>>>> code
>>>> in the
>>>> Smacklet class
>>>>
>>>> class com.flashdb.domain.Smacklet
>>>> {
>>>> private var reg:Boolean =
>>>> Object.registerClass("com.flashdb.domain.Smacklet",com.flashdb.domain.Smacklet);
>>>>
>>>> // Rest of class code
>>>> }
>>>>
>>>>
>>>> if it doesnt work after that then i try a liberal dose of swearing. :)
>>>>
>>>> good luck.
>>>>
>>>> Martin
>>>>
>>>> Using Tomcat but need to do more? Need to support web services,
>>>> security?
>>>> Get stuff done quickly with pre-integrated technology to make your job
>>>> easier
>>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>>>> Geronimo
>>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>>>> _______________________________________________
>>>> Openamf-user mailing list
>>>> Openamf-user@...
>>>> https://lists.sourceforge.net/lists/listinfo/openamf-user
>>>>
>>>>
>>>
>>>
>>> Using Tomcat but need to do more? Need to support web services,
>>> security?
>>> Get stuff done quickly with pre-integrated technology to make your job
>>> easier
>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>>> Geronimo
>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>>> _______________________________________________
>>> Openamf-user mailing list
>>> Openamf-user@...
>>> https://lists.sourceforge.net/lists/listinfo/openamf-user
>>>
>>
>>
>> Using Tomcat but need to do more? Need to support web services, security?
>> Get stuff done quickly with pre-integrated technology to make your job
>> easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>> Geronimo
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>> _______________________________________________
>> Openamf-user mailing list
>> Openamf-user@...
>> https://lists.sourceforge.net/lists/listinfo/openamf-user
>>
>
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Openamf-user mailing list
> Openamf-user@...
> https://lists.sourceforge.net/lists/listinfo/openamf-user
>
|