Search code examples
apache-flexgraphicsflex4drawborder-container

How to draw a circle inside Border Container using graphics object?


My basic requirement is to draw a circle inside a BorderContainer with the layout set to BasicLayout

I run this method in the CREATION_COMPLETE event of the BorderContainer object.

   this.graphics.beginFill(0xff0000);
   this.graphics.lineStyle(1, 0x00ff00);
   this.graphics.drawCircle(0, 0, 50);
   this.graphics.endFill();

Sorry to be blunt, but why don't I see anything? I know I must be missing something VERY basic here. Can I just draw like this OR should I draw in some other event?

P.S: I know that I can create a Ellipse object and easily add it to the border container but I would like to know how I can do this using the graphics object.


Solution

  • Back in the olden days you would override updateDisplayList and do this sort of drawing there. I'm guessing things are getting refreshed at some point AFTER creation complete. Since you are drawing rather than adding an object to the stage, your circle isn't really part of any kind of lifecycle and will get wiped clean whenever the display list is dirtied/redrawn. Hope that helps.