国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

3.20.根據呼出組件設置對話框的尺寸和位置

2024-04-27 13:51:50
字體:
來源:轉載
供稿:網友
3.20.1 問題
我們需要生成一個對話框,該對話框具有和呼出它的組件相同尺寸和位置。
3.20.2 解決辦法
使用MouseEvent 的target 屬性來確定調用該方法的組件的信息,同時,使用mx.geometry.Rectangle 類來確定呼出的組件實際寬高及其在Stage 內的位置。
3.20.3 討論
為了保證無論應用程序的layout 設定為absolute, horizontal,還是vertical,對話框都會添加到應用程序中并且顯示在正確的位置,你需要創建一個可關閉的TabNavigator,該TabNavigator 的所有tab 項都是可關閉的,關閉某個tab 項的時候即從TabNavigator 中移除對應tab 項下的子組件。將對話框的includeInLayout 屬性設置為false 以保證應用程序不改變對話框的位置。
+展開
-ActionScript
dialogue = new Dialogue();
mx.core.Application.application.rawChildren.addChild(dialogue);
dialogue.includeInLayout = false;

getBounds 方法返回一個帶x 和y 位置的矩形,同時DisplayObject 的寬和高作為傳入到方法里面的對象的成員屬性。在下面的例子里,Stage 作為傳入getBounds 方法的DisplayObject 參數,這樣,就會根據整個應用返回組件的位置信息了。
+展開
-XML
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxmlwidth="700"
height="500left="50top="50verticalGap="50">

<mx:Script>
<![CDATA[
import mx.core.Application;
import mx.core.UIComponent;
private var dialogue:Dialogue;
private function placeLabel(event:MouseEvent):void
{
if(dialogue == null)
{
dialogue = new Dialogue();
mx.core.Application.application.rawChildren.addChild(dialogue);
dialogue.includeInLayout = false;
}v
var rect:Rectangle = (event.target as
UIComponent).getBounds(this.stage);
dialogue.x = rect.x;
dialogue.y = rect.y + (event.target as
UIComponent).height;
}

]]>
</mx:Script>
<mx:HBox horizontalGap="50">
<mx:Label text="First label."/>
<mx:Button label="Place Firstclick="placeLabel(event)"/>
</mx:HBox>
<mx:HBox horizontalGap="50">
<mx:Label text="Second label."/>
<mx:Button label="Place Secondclick="placeLabel(event)"/>
</mx:HBox>
<mx:HBox horizontalGap="50">
<mx:Label text="Third label."/>
<mx:Button label="Place Thirdclick="placeLabel(event)"/>
</mx:HBox>
<mx:HBox horizontalGap="50">
<mx:Label text="Fourth label."/>
<mx:Button label="Place Fourthclick="placeLabel(event)"/>
</mx:HBox>
</mx:VBox>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 钦州市| 上犹县| 栖霞市| 杭州市| 闵行区| 林芝县| 汉沽区| 于都县| 石景山区| 高尔夫| 怀集县| 垫江县| 肃北| 彰化市| 铜川市| 疏附县| 武安市| 兴业县| 象州县| 富锦市| 梁山县| 诸城市| 辉南县| 崇信县| 会理县| 清流县| 甘孜县| 平南县| 民勤县| 沈丘县| 普定县| 兴义市| 商水县| 沈阳市| 甘南县| 芦山县| 台南县| 永城市| 瓦房店市| 田阳县| 威远县|