2 Replies Latest reply on Aug 12, 2009 10:04 AM by manofspirit

    Questions about Functions as Object

    manofspirit Level 1

      Hello guys

       

       

      Lets suppose that one of my component have a function like this

       

      private var resultHandler(event:ResultEvent):void{

            var xml:XML = XML(event.result);

           //do work

      }

       

       

       

      now i instantiate another component, and i want to pass above function as a parameter to the newly created component.

       

      var newComp:NewComp = NewComp();

      newComp.passFunction(resultHandler);

       

       

      ////////

      New Component

      public function passFunction(func:Function):void{

      addEventListener(Event.RESULT, func);

      }

       

       

      will above thing work?

      If not, How can i do this?

       

      Thanks a lot