我有一個畫布,上面畫矩形等形狀。當我使用自定義鼠標向下/鼠標移動處理程序移動形狀時,形狀可以超出父界。如何防止在Flex/Flash中的父容器外面拖動?
我檢查,如果孩子在外面父母的束縛將其歸:當我去左邊或頂部邊界之外
var bounds:Rectangle = this.getBounds(this.parent);
var p:Point;
if (bounds.x <0) {
p = new Point(0,0);
p.offset(-bounds.x,0);
}
if (bounds.y <0) {
if (!p) p = new Point(0,0);
p.offset(0,-bounds.y);
}
if (bounds.y+bounds.height > this.parent.height) {
if (!p) p = new Point(0,0);
p.offset(0,-bounds.y-height+this.parent.height);
}
if (bounds.x+bounds.width > this.parent.width) {
if (!p) p = new Point(0,0);
p.offset(-bounds.x-width+this.parent.width,0);
}
if (p) {
trace("invoking snapInside ", p);
snapInside(p);
的snapInside方法被調用。但是當孩子拖到右邊或底部邊界之外時,我發現Flex/Flash運行時會自動擴展父代的高度和寬度。所以說父母的大小最初是800x600,如果孩子Y的邊界超過800像20像素,我發現this.parent.height自動調整大小爲flex到820!
當孩子超出父母的原始界限時,我該如何防止父母調整大小?
爲什麼不startDrag(false,new Rectangle(... bounds ...)) – alxx 2010-11-23 07:24:39