Search code examples
flashactionscript-3adobeair

Draw bottom rounded corner


How can i draw a shape, that is only rounded at it's bottom, without using libraries?

enter image description here

  var _myShape:Shape = new Shape();
      _myShape.graphics.lineStyle(4,0x000000,1,true,....);
      _myShape.graphics.drawRoundRect(0,0,50,50,10);

Solution

  • if you don't want to use Flex libraries (as you've commented on Glenn's answer) and if you're only concerned will fills, you could employ a masking technique on your sprites.

    var sprite:Sprite = new Sprite();
    sprite.graphics.beginFill(0xFF0000, 1.0);
    sprite.graphics.drawRoundRect(0, 0, 300, 200, 100, 100);
    sprite.graphics.endFill();
    
    var spriteMask:Shape = new Shape();
    spriteMask.graphics.beginFill(0);
    spriteMask.graphics.drawRect(0, sprite.height / 2, sprite.width, sprite.height / 2);
    spriteMask.graphics.endFill();
    
    sprite.mask = spriteMask;
    sprite.addChild(spriteMask);
    
    addChild(sprite);
    

    including strokes is a little trickier, but still possible.