3 Replies Latest reply on Dec 4, 2013 5:00 PM by Ned Murphy

    Instance name

    asydd

      Flash CC

      I'm creating a number of buttons using the below:

       

      setBut('butPass', 'Password', bX, bY, bS);

      setBut('butUser', 'User Name',bX, bY+=80, bS);

      // etc

       

      function mcP(e:MouseEvent):void

      {

            aTf.text = e.target.name+": " + ar[0] + ' ~ ' + ar[1] + ' ~ ' + ar[2];

      }

       

      function setBut(vMcn:String, vBt:String, vX:int, vY:int, vS:Number):void

      {

                var vMc = new ButtOn;

                vMc.name = vMcn;

                vMc.addEventListener(MouseEvent.CLICK, mcP);

                vMc.txt.text = vBt;

                vMc.txtS.text = vBt;

                vMc.x = vX;

                vMc.y = vY;

                vMc.scaleX = vS;

                vMc.scaleY = vS;

                addChild(vMc);

      }

       

      I try naming the new instance (vMc.name = vMcn;) but on using the different buttons I get the following returns:

      instance4, instance8, instance12, instance16   etc.

       

      What am I doing wrong?  Thanks...