0 Replies Latest reply on Jul 14, 2010 2:16 PM by thenewmexican62

    Question about Graphics object.

    thenewmexican62

      Does a child inherit the Graphics object from its parent.

      When the draw function is invoked, both lines appear on the parent canvas.

       

      AM I missing something.

       

      if I have the following hierarchy

      <mx:Canvas id="imParent" creationComplete(init)">

         <mx:Script>
         
              <![CDATA[

       

                     private function init(event:Event):void {

       

                          parentGraphics = imParent.graphics;

                          childGraphics = imChild.graphics;

       

       

                     }

       

                     private function draw():void {

       

                          //: Draws on parent canvas

                          parentGraphics.moveTo(0,0);

                          parentGraphics.lineTo(50,0):

       

                           //: Also draws on parent canvas

                          childGraphics.moveTo(10,10);

                          childGraphics.lineTo(10,50);

                     }

                     private var parentGraphics:Graphics;

                     private var childGraphics:Graphics;

                ]]>
          </mx:Script>

       

       

        <mx:Canvas id="imChild">

      </mx:Canvas>

      </mx:Canvas>