1 Reply Latest reply on Jun 13, 2006 4:31 AM by blemmo

    pass value from 1 function to another inside itself

      how might I pass the value of 'i' from a function to an 'onRelease' function that is contained within the original function?

      I have got my code to work (I have attached it to message) but am not happy with the lines in the 'onRelease' function:
      var thisNum = this._name.substr(4, 1);
      thisNum = this._name.substr(4, 1);

      I don't think this is an efficient way of doing it & wondered if anyone had a better suggestion?
      Thanks in advance if anyone can help.

        • 1. Re: pass value from 1 function to another inside itself
          blemmo Level 1
          There's nothing wrong with that code, as long as i < 10. There are other ways though:
          a) store 'i' in a variable inside the object that has the event:

          myMC.id = i;
          myMC.onRelease = function(){
          trace( this.id );

          b) assign the value of 'i' via an extra function ('i' gets passed by value then and will have the value from the moment of assigning):

          function setRelease( mc:MovieClip, id:Number ){
          mc.onRelease = function(){
          trace ( id );
          // in the loop / other function:
          setRelease( myMC,i );