3 Replies Latest reply on Nov 14, 2007 3:05 PM by dsdsdsdsd

    how to call a referenced object.method

    dsdsdsdsd Level 1
      hello;

      I am trying to call a class.method using a reference to the class:


      my_class = function()
      { this.listener_method = function( args )
      { trace( args ) ;
      }
      my_object.register_something ( this , "listener_method" ) ;
      }

      my_object = new Object();
      my_object.register_something = function( arg_reference_to_class_or_object , arg_method )
      { // ?????????????????
      arg_reference_to_class_or_object.arg_method( "howdy" ) ;
      // so here I want to use the received arguments to call back;
      // in Lingo I just use 'call' but Flash's 'call' does something different;
      };

      any thoughts?

      thanks
      dsdsdsdsd









        • 1. how to call a referenced object.method
          dsdsdsdsd Level 1
          partial solution:

          arg_reference_to_class_or_object[ arg_method ].call( "howdy" ) ;

          PROBLEM the argument 'howdy' is not being sent;

          dsdsdsdsdsd
          • 2. Re: how to call a referenced object.method
            clbeech Level 3
            It's very difficult to understand what exactly it is you're trying to achieve here, there are several things wrong with your code. is this AS2 or AS3? Are you trying to pass a parameter to a method?(this seems most likely) Are you trying to construct a Listener/Broadcaster system? Are you trying to construct a 'class' file? It's very hard to say.

            Any of these things can be done to pass the argument paremeter, but a 'class file' is a seperate file in which you can encapsulate code and methods, then call instances of the class within another document and apply the methods of the class you've constructed. In the code you've given below, you are not constructing a 'class'.

            In order to construct a class with a method of this type, first open a new ActionScript file document, and add the first code in the example below, save the file with the EXACT name of the class in a new folder or directory. then open another new FLA document, and add the second code int he example below, save the file within the SAME directory as the .as file. Then test the FLA. put anything you want within the 'register' method parameter and it will trace to the output panel.
            • 3. Re: how to call a referenced object.method
              dsdsdsdsd Level 1
              clbeech, thanks for responding; I had not "subscribed to this topic" so I did not realise that there was a response;

              I am using AS 1;

              I create OBJECTS using:
              --------------------------------------------------
              blue_book = new Object();
              blue_book.appraise_value = function( arg_class, arg_method )
              {

              if ( arg_class.color == "purple" )
              { arg_class[ arg_method ].call( 0 ) ;///PROBLEM - not sending argument
              }
              else if ( arg_class.color == "red" )
              { arg_class[ arg_method ].call( 100000000 ) ;///PROBLEM - not sending argument
              };

              }




              I create CLASSES using:
              ----------------------------------------------------------------------
              car_class = function( args_color )
              {

              this.color = args_color;
              this.wait_for_reply = function( argi )
              { trace( argi ) ;
              }
              blue_book.appraise_value ( this , "wait_for_reply" ) ;

              }




              and then call instances:
              ----------------------------------------------------------------------
              my_car = new car_class( "red" ) ;
              my_other_car = car_class( "purple" ) ;




              so my problem is sending values in the call() ;


              thanks for your time
              Shannon