1 Reply Latest reply on Feb 25, 2010 9:10 AM by Gregory Lafrance

    placing a new component in aq canvas

    eranweingart

      i have a canvas.

      after canvas.addChild(comp), the comp is placed at the top left location of the canvas.

      i tried to change the x,y properties of the comp, but it doesnt change anything.

      i think it has something to do with the layout of the canvas, but it doesnt have layout property.

        • 1. Re: placing a new component in aq canvas
          Gregory Lafrance Level 6

          Does your Canvas have a width/height set?

           

          This code works, how does your differ?

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="init();">
            <mx:Script>
              <![CDATA[
                import mx.controls.Button;
                private function init():void{
                  var btn:Button = new Button();
                  btn.label = "Test";
                  btn.x = 100;
                  btn.y = 100;
                  canvas.addChild(btn);
                }
              ]]>
            </mx:Script>
            <mx:Canvas id="canvas" width="500" height="500" 
              backgroundColor="0xFFFFFF"/>  
          </mx:Application>


          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services