2 Replies Latest reply on Feb 26, 2008 2:17 AM by anirudhs

    AS3 Echo?

    jefflemon Level 1
      In a loop I dynamically set the value of a function:

      fnc1 = "function handleClick2(event:MouseEvent) : void{this.currentState = myvar;}";

      }

      But how do I later call this out in the as3, for example the php would be:
      echo $fnc1;

      what would the as3 be?
        • 1. Re: AS3 Echo?
          ntsiii Level 3
          That line assigns a STRING to the fnc1 variable. It does not create a function or "set the value of a function"

          What are you trying to accomplish?

          Tracy
          • 2. Re: AS3 Echo?
            anirudhs Level 2
            Hi,

            If you are trying to create closures in a loop and later call them, take a look at the following code:

            var arr:Array = new Array();

            for ( var i:int = 0; i < 5; i++ )
            {

            arr.push(function():void{trace(i)});
            }

            for ( var i:int = 0; i < 5; i++ )
            {

            var fn:Function = arr as Function;
            fn();
            }