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

首頁(yè) > 網(wǎng)站 > WEB開(kāi)發(fā) > 正文

3.20.根據(jù)呼出組件設(shè)置對(duì)話框的尺寸和位置

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

getBounds 方法返回一個(gè)帶x 和y 位置的矩形,同時(shí)DisplayObject 的寬和高作為傳入到方法里面的對(duì)象的成員屬性。在下面的例子里,Stage 作為傳入getBounds 方法的DisplayObject 參數(shù),這樣,就會(huì)根據(jù)整個(gè)應(yīng)用返回組件的位置信息了。
+展開(kāi)
-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>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 扬中市| 定南县| 墨玉县| 开江县| 佛教| 阿城市| 海兴县| 蓬安县| 河北省| 郎溪县| 东兰县| 鄂州市| 原阳县| 迁安市| 弥勒县| 平乐县| 中卫市| 同江市| 馆陶县| 兰西县| 都昌县| 博白县| 厦门市| 无为县| 洞头县| 建德市| 绥中县| 依安县| 木里| 铜川市| 保山市| 建德市| 左贡县| 兰考县| 吴桥县| 富蕴县| 嘉峪关市| 昌平区| 沿河| 内江市| 红安县|