国产探花免费观看_亚洲丰满少妇自慰呻吟_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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 唐山市| 呈贡县| 东乌珠穆沁旗| 台山市| 辽宁省| 北川| 青川县| 平乡县| 环江| 安多县| 苏尼特左旗| 襄樊市| 临西县| 漾濞| 彭阳县| 海兴县| 教育| 托克逊县| 固安县| 体育| 广水市| 阿荣旗| 正安县| 莒南县| 吉木乃县| 屯昌县| 神农架林区| 库伦旗| 仙居县| 泽普县| 称多县| 陇西县| 定陶县| 沁源县| 高雄县| 易门县| 邯郸县| 长海县| 正宁县| 吉木乃县| 竹溪县|