5 Replies Latest reply on Nov 9, 2011 7:47 AM by Ned Murphy

    Add stroke to an array

    Owen_Alextoys

      Hello,

       

           I'm trying to create a simple coloring book app and I've got it mostly working based on tutorials and code I've found on the web. I'm using an array for my color swatches and I'm trying to add a stroke but it's not working. The markers in the array are based on a symbol called "Colours"

      Image.jpg

      Here's the action script I'm using.

       

      //Array to hold the colours

      var colorArray:Array=new Array(0xE97DB1,0xF58240,0xF9ED41,0x82C34D,0x00B0F0,0x935CA4,0xFFFFFF);

       

       

      //A new instance of the colour transform class.

      var colorTrans:ColorTransform=new ColorTransform;

       

       

      var currentColor:int=0;

       

       

      //This adds the ovals on the stage with the corresponding colour from the array

      //and with the mouse click event.

      for (var i:int = 0; i < colorArray.length; i++) {

           var c = new Colours();

           c.y=500+i*50;

           c.buttonMode=true;

           addChild(c);

       

       

           colorTrans.color=colorArray[i];

           c.transform.colorTransform=colorTrans;

           c.addEventListener(MouseEvent.CLICK, ovalsClick);

           c.arrayIndex=i;

      }

       

       

      //This sets the currentColour value from the dynamic property array index.

      function ovalsClick(e:MouseEvent):void {

           currentColor=e.currentTarget.arrayIndex;

      }

       

       

      //Adds the mouse click event to the holder.

      holder.addEventListener(MouseEvent.CLICK, holderHandler);

       

       

      //This function changes the colour of the movie clip inside

      //holder when it is clicked.

      function holderHandler (e:MouseEvent):void {

         for (var i:int = 0; i < holder.numChildren; i++) {

             if (holder.getChildAt(i).hitTestPoint(mouseX,mouseY,true)) {

                 colorTrans.color=colorArray[currentColor];

                 holder.getChildAt(i).transform.colorTransform=colorTrans;

             }

         }

      }

       

       

      Thanks in advance,

       

      -Owen