1 Reply Latest reply on Dec 28, 2006 1:23 AM by Devendran

    closure workaround (i think)?

    lreadl
      I've defined a custom objectO in an .as file, and within functionA in that objectO, I want to set the onPress function of a movieclipM to functionB which is also in that objectO. I wrote in functionA:

      movieclipM.onPress = functionB;

      but when I click the movieclipM with my mouse, functionB does not execute. I thought maybe onPress didn't know which object functionB was in (which is what a closure would tell it, right?) So I tried this:

      movieclipM.onPress = function() {
      functionB.call(objectO);
      }

      thinking that the call function would call functionB of the given objectO, but that doesn't work either. How do I make movieclip.onPress call functionB? FunctionB calls other functions in objectO, so I don't want to duplicate all that code. Also, I'd prefer not to put any code in movieclipM I can help it, but I guess I might have to.