1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| import mx.controls.Button;
private var oW:Number;
private var oH:Number;
private var oX:Number;
private var oY:Number;
private var resizeHandler:Button = new Button();
private var oPoint:Point = new Point();
private var can:Canvas = new Canvas();
private function creation():void
{
this.resizeHandler.width = 50;
this.resizeHandler.height = 50;
this.resizeHandler.styleName = "resizeHandler";
this.rawChildren.addChild(resizeHandler);
this.resizeHandler.y = this.unscaledHeight - resizeHandler.height - 1;
this.resizeHandler.x = this.unscaledWidth - resizeHandler.width - 1;
this.resizeHandler.addEventListener(MouseEvent.MOUSE_DOWN, resizeDownHandler);
this.can.width = 250;
this.can.height = 250;
this.can.styleName = "canvas";
this.rawChildren.addChild(can);
can.addChild(resizeHandler);
}
public function resizeDownHandler(event:MouseEvent):void {
this.can.addEventListener(MouseEvent.MOUSE_MOVE, resizeMoveHandler);
this.can.addEventListener(MouseEvent.MOUSE_UP, resizeUpHandler);
this.oPoint.x = mouseX;
this.oPoint.y = mouseY;
this.oPoint = this.localToGlobal(oPoint);
}
public function resizeMoveHandler(event:MouseEvent):void {
var xPlus:Number = this.can.mouseX - this.oPoint.x;
var yPlus:Number = this.can.mouseY - this.oPoint.y;
if (this.menuPanel.height == 150) {
if (this.oW + xPlus > 215) {
this.width = this.oW + xPlus;
}
if (this.oH + yPlus > 200) {
this.height = this.oH + yPlus;
}
} else {
if (this.oW + xPlus > 140) {
this.width = this.oW + xPlus;
}
if (this.oH + yPlus > 80) {
this.height = this.oH + yPlus;
}
}
}
public function resizeUpHandler(event:MouseEvent):void {
this.can.removeEventListener(MouseEvent.MOUSE_MOVE, resizeMoveHandler);
this.can.removeEventListener(MouseEvent.MOUSE_UP, resizeUpHandler);
this.oW = this.width;
this.oH = this.height;
this.oX = this.x;
this.oY = this.y;
} |
Partager