6 Replies Latest reply on Nov 23, 2006 5:18 PM by dimival

    Flex - Java Explanation

    dimival Level 1
      We all know that you can have an ActionScript class which "maps" to a Java class and it is converted from Flex to Java and from Java to Flex, but does anyone know how this conversion is made? we also know that properties must have the same name on both classes, but what if there are getters and setters? what if i don't "map" a property? and that kind of questions

      I would appreciate if anyone could explain how does Flex converts from AS to Java and viceversa.
        • 1. Re: Flex - Java Explanation
          peterent Level 2
          The Flex 2 Developer's Guide explains how the mapping between Java and ActionScript types is done.
          • 2. Flex - Java Explanation
            dimival Level 1
            Found it but not very clear, i have a property whose getter/setter have different names, i am not explaining why this but trust me that it works and is necessary for some java purposes. Flex seems to get confused by this, example:

            private String testString

            public String getTestStringVO( ) {
            return testString;

            public void setTestStringVO(String value) {
            testString = value;

            So that's why i want to know what does flex exactly do when converting from one language to another
            • 3. Re: Flex - Java Explanation
              Flex won't look at the getter and setter names! What it does is look at what your method does.. for instance.. "return testString;" is what one of your methods does. Ok so when the client requests the testString variable, it will look for a method that returns that variable. Do you understand?
              • 4. Re: Flex - Java Explanation
                dimival Level 1
                Ummm that is weird though because for this same case Flex obtained a null String and in Java that String was not null.
                Then i changed the property's name to testStringVO so it would match it's getter and setter and then it worked, Flex obtained the Java String correctly.
                You said that Flex checks for the return type, i don't think so since in the example the property that is being returned is the one i am asking in Flex and it obtains null.

                • 5. Re: Flex - Java Explanation
                  peterent Level 2
                  See: Flex 2 Developer's Guide > Data Access and Interconnectivity > Configuring Data Services > Serializing data

                  Also do a search on java in the Flex 2.0 livedocs to get all the info.

                  The Flex gateway uses Java reflection to determine what to match.
                  • 6. Re: Flex - Java Explanation
                    dimival Level 1
                    Ok i will look at those references hoping to find it. I mark this as the answer because if i dont find it on the documentation i doubt someone would explain it to me in detail