'implements Serializable' versus 'extends ASObject'
Todd Hivnor <[email protected]>
| Newsgroups | gmane.comp.java.openamf.user |
|---|---|
| Message-ID | <[email protected]> |
I'm working on a new application using OpenAMF. I want to send objects from Java to Flash, and from Flash to Java. I hope to define the same class in both Java and Flash, such that Java can create the object, send it to Flash, and have Flash create an instance of it. The same should work in reverse. I want more than just an ASObject, I want full-on objects, with the methods available. Also, I want to be able to nest my objects. I understand that I must call Object.registerClass in Flash to set up the association between the Flash class and the Java class. (Seems weird that I need to do this under AS2.0, but it works, so I do it.) I've read the CarbonFive docs, at: http://carbonfive.sourceforge.net/astranslator/api/com/carbonfive/flash/package-summary.html On the Java side, I can either implement Serializable and a bunch of getters, or I can extend ASObject, putting my data directly into the ASObject's hashmap. If I extend ASObject on my Java class, and am careful to call setType to the proper classname, I can send objects from Java to Flash, and they come out correct in Flash. (By "correct" I mean the object in Flash has the methods defined by the ActionScript class.) However, if I send an instance from Flash to Java, Java can't create real instances. All it can create is instances of ASObject. I have tried using ASTranslator directly, and can't get anything but instances of ASObject. I can't cast it to the real Java object. On the other hand, if I implement Serializable on my Java class, I can use the ASTranslator to convert objects coming from Flash to the correct Java class (Using ASTranslator().fromActionScript(o)). However, those objects then break on the flash side. They come across as just dumb data ... the methods are gone. If I implement Serializable _and_ extend ASObject, then I can not use the ASTranslator to convert objects coming from Flash to the correct Java class. I just get instances of ASObject again. Sending objects from Java to Flash does work. So I'm at a loss. I can send objects in either direction, but never send them both ways. Am I missing something here? Is there a way to make this work? Is there a working example of this type of communication? I'm using the Flash 8 IDE, targeting the Flash 7 player, using ActionScript 2.0, using OpenAMF RC11, using Java 1.4, and running on Tomcat. - Todd ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl