2 Replies Latest reply on Apr 18, 2011 8:37 AM by j0ecamel83

    paint app not drawing on panel help

    j0ecamel83

      I've written a basic paint app, based off of a couple examples, and this example http://www.jamesward.com/2010/03/22/flex-paint-updated-to-flex-4.  My problem is that the paint function is drawing behind my panel and not on top or in it. how do i fix this, any ideas? you can ignore the labstatus label it was used for bug testing.

       

       

                  protected var isDrawing:Boolean = false;
                  protected var x1:int;
                  protected var y1:int;
                 
                  protected var x2:int;
                  protected var y2:int;
                 
                  private var lineColor:uint = 0x000000;
                 
                  protected function draw_clickHandler(event:MouseEvent):void
                  {
                     addEventListener(MouseEvent.MOUSE_DOWN, mDown);
                     addEventListener(MouseEvent.MOUSE_MOVE,mMove);
                     addEventListener(MouseEvent.MOUSE_UP,mUp);
                    
                  }

       

                  protected function mDown (event:MouseEvent): void
                  {
                      x1 = pan.mouseX;
                      y1 = pan.mouseY;
                      isDrawing = true;
                      labstatus.text = "da";
                     
                  }
                 
                  protected function mMove(event:MouseEvent): void
                  {
                      if(!event.buttonDown)
                      {
                          isDrawing = false;
                          labstatus.text = "mouse up moving";
                      }
                     
                      x2 = pan.mouseX;
                      y2 = pan.mouseY;
                     
                      if (isDrawing)
                      {
                          pan.graphics.lineStyle(6,lineColor);
                          pan.graphics.moveTo(x1,y1);
                          pan.graphics.lineTo(x2,y2);
                         
                          x1 = x2;
                          y1 = y2;
                      labstatus.text = "Drawing line" + x1 +" " + y1;   
                      }
                  } //end mMove
                 
                  protected function mUp(event:MouseEvent):void
                  {
                      isDrawing = false;
                  }
                 
                 
                  protected function lineColorPicker_changeHandler(event:ColorPickerEvent):void
                  {
                      lineColor = event.target.selectedColor;
                  }

       

              ]]>
          </fx:Script>

       

          <s:Panel x="32" y="82" width="543" height="227" id="pan">
         
              <s:controlBarContent>
              <mx:ColorPicker width="38" height="23" id="lineColorPicker" change="lineColorPicker_changeHandler(event)"/>
              <s:Button label="paint" id="draw" click="draw_clickHandler(event)"/>
             
          </s:controlBarContent>
              <s:Label x="57" y="57" width="97" height="45" id="labstatus"/>
          </s:Panel>
         
      </s:Application>