3 Replies Latest reply on Aug 21, 2008 9:26 AM by tjfeuling

    Drawing in canvas not working

    tjfeuling
      I'm trying to draw inside a canvas in the updateDisplayList method. My current code is shown below.

      Everything works just fine if I don't clone the borderMetrics; however, when I do use borderMetrics.clone(), the rectangle will not be display. The _edge variabe is just a member variable of EdgeMetrics and the only other thing in this canvas is a Button. Does anybody know why I can't draw to the screen when i use borderMetrics.clone()? Thanks for the help.
        • 1. Re: Drawing in canvas not working
          tjfeuling Level 1
          Ok... So I figured out my problem. I had a backgroundColor set, in the defaults.css file which I didn't notice, for the Canvas control which was drawing over my rectangle. Now my question is. How do I draw over the backgroundColor. I tried to create a UIComponent as a child and used that for drawing which drew; however, I need to be able to draw inside my chrome (the area which viewMetrics specifies) which if I place the UIComponent in that area the drawing doesn't show up. Any ideas to allow me to draw inside my chrome?
          • 2. Re: Drawing in canvas not working
            Level 7

            "tjfeuling" <webforumsuser@macromedia.com> wrote in message
            news:g8ju46$3vh$1@forums.macromedia.com...
            > Ok... So I figured out my problem. I had a backgroundColor set, in the
            > defaults.css file which I didn't notice, for the Canvas control which was
            > drawing over my rectangle. Now my question is. How do I draw over the
            > backgroundColor. I tried to create a UIComponent as a child and used that
            > for
            > drawing which drew; however, I need to be able to draw inside my chrome
            > (the
            > area which viewMetrics specifies) which if I place the UIComponent in that
            > area
            > the drawing doesn't show up. Any ideas to allow me to draw inside my
            > chrome?

            I think that probably Canvas is drawing its background in updateDisplayList,
            so if you override that function and draw your stuff without calling
            graphics.clear() after the super.updateDisplayList call, it should do what
            you want.

            You may also want to look at adding to rawChildren instead of children.

            HTH;

            Amy


            • 3. Re: Drawing in canvas not working
              tjfeuling Level 1
              I ended up adding a UIComponent to the rawChildren which worked. Thanks for the help.