1 Reply Latest reply on Jul 29, 2009 12:54 PM by Travis Lazar

    Accessing a method in a Javascript object from Flex

    _CoreDragon Level 1

      Hey All,


      How would I access a method in a javascript object from flex? I read that I can use the ExternalInterfaces.call method to call Javascript functions - but they are direct functions and not functions of an object...


      For example,


      If I have this in JavaScript

      function Car()


        this.wheels = 4;



      function Car_printNumberOfWheels()


        return this.wheels;



      Car.prototype.printNumberOfWheels = Car_printNumberOfWheels


      var myCar = new Car();

      // alert(myCar.printNumberOfWheels) would alert "4"


      How can I call the printNumberOfWheels function in the myCar object from Flex?



        • 1. Re: Accessing a method in a Javascript object from Flex
          Travis Lazar

          The easiest way to use a simple Javascript object would be to use the HTTPService component. Host your javascript on a server somewhere and use the HTTPService to query a jsp page which allows you access to your javascript objects.


          The better but more complicated way would be to use java and expose your methods and objects as a web service. Web services are far more complicated and seem outside of the scope of this problem.