package components.Tools
{
    import mx.core.UIComponent;
    import flash.display.Sprite;
    

    // Essa classe define e desenha o retangulo em volta do objeto selecionado
    // por completo com os quadrados que controlam o resize
    public class BannerRect extends UIComponent{
        public var tl:BannerBox; // quadrado de cima a esquerda TopLeft
        public var bl:BannerBox; // bottonLeft
        public var tr:BannerBox; // topRight
        public var br:BannerBox; // bottonRight
        public var mr:BannerBox; // midleRight
        public var ml:BannerBox; // middleLeft
        public var mt:BannerBox; // middleTop
        public var mb:BannerBox; // middleBotton
        
        public function BannerRect(){
            new Sprite();
            tl = new BannerBox(); tl.name = 'tl';
            bl = new BannerBox(); bl.name = 'bl';
            tr = new BannerBox(); tr.name = 'tr';
            br = new BannerBox(); br.name = 'br';
            ml = new BannerBox(); ml.name = 'ml';
            mr = new BannerBox(); mr.name = 'mr';
            mt = new BannerBox(); mt.name = 'mt';
            mb = new BannerBox(); mb.name = 'mb';
            this.addChild(tl);
            this.addChild(bl);
            this.addChild(tr);
            this.addChild(br);
            this.addChild(ml);
            this.addChild(mr);
            this.addChild(mt);
            this.addChild(mb);
            redraw(1, 1);
        }
        public function redraw(w:Number, h:Number):void{
            this.graphics.clear();
            this.graphics.lineStyle(1, 0x33ffff, 1.0); // cor da linha da borda da seleção
            this.graphics.beginFill(0xaaffff, 0.1); // aqui a cor e o alfa que cobre a selecao
            this.graphics.drawRect(-4, -4, w+8, h+8);
            this.graphics.endFill();
            tl.x = -6;
            tl.y = -6;
            bl.x = -6;
            bl.y = 3+h;
            tr.x = 1 + w;
            tr.y = -6;
            br.x = 1 + w;
            br.y = 3 + h;
            ml.x = -6;
            ml.y = h/2;
            mr.x = 1 + w;
            mr.y = h/2
            mt.x = w/2 - 3;
            mt.y = -6;
            mb.x = w/2 - 3;
            mb.y = 3 + h;
        }
    }
}