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

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

3.29.控制子組件的位置和滾動

2024-04-27 13:51:52
字體:
來源:轉載
供稿:網友
3.29.1 問題
你需要滾動一個父組件并且移動除了一個子組件之外的其它所有子組件。
3.29.2 解決辦法
在容器定義的scrollChildren方法內,根據verticalScrollPosition屬性重新定位子組件。
3.29.3 討論
容器的scrollChildren 方法測量容器的contentPane 這個DisplayObject,它包含了添加到容器中的所有子組件,同時確定在滾動的時候測量到的子組件要顯示出多少。contentPane則根據horizontalScrollPosition 和verticalScrollPosition 屬性移動。容器自身則像是contentPane 的遮罩一樣,并且contentPane 的位置由滾動條的相對位置以及容器的ViewMetrics 屬性值確定。

下面的代碼段把頂部組件的y 位置存儲起來,允許用戶拖拽組件的同時保持組建距離父親容器頂部位置的不變,而正常設置其它組件:
+展開
-XML
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxmlwidth="500"
height="500">

<mx:Script>
<![CDATA[
private var top:TopComponent;
//store the y position
private var topY:Number;
private function showTop():void
{
top = new TopComponent();
addChild(top);
top.verticalScrollPolicy = "none";
top.x = 200;
top.y = 100;
topY = top.y;
top.addEventListener(MouseEvent.MOUSE_DOWN, dragTop);
}
private function dragTop(event:Event):void
{
top.startDrag(falsethis.getBounds(stage));
top.addEventListener(MouseEvent.MOUSE_UP,
stopDragTop);
}p
private function stopDragTop(event:Event):void
{
topY = top.y;
top.stopDrag();
top.removeEventListener(MouseEvent.MOUSE_UP,
stopDragTop);
}o
override protected function scrollChildren():void
{
super.scrollChildren();
if(top){
top.y = verticalScrollPosition+topY;
//
top.verticalScrollPosition =
this.verticalScrollPosition/height *
top.height;
}
}

]]>
</mx:Script>
<mx:Panel>
<mx:Label text="LABEL BABEL"/>
<mx:Label text="LABEL BABEL"/>
<mx:Label text="LABEL BABEL"/>
</mx:Panel>
<mx:Panel y="500height="200">
<mx:Label text="LABEL BABEL"/>
<mx:Label text="LABEL BABEL"/>
<mx:Label text="LABEL BABEL"/>
</mx:Panel>
<mx:Button click="showTop()"/>
</mx:Canvas>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙江县| 五家渠市| 南充市| 祁门县| 辉县市| 莒南县| 宁都县| 湘西| 兴和县| 东乌珠穆沁旗| 呼和浩特市| 五大连池市| 峡江县| 文化| 乌兰县| 惠水县| 福贡县| 金湖县| 丹寨县| 依兰县| 简阳市| 六安市| 高要市| 泽州县| 大渡口区| 吕梁市| 宁河县| 炉霍县| 汨罗市| 宁津县| 白城市| 措勤县| 利川市| 安龙县| 宁德市| 城步| 湟源县| 尉犁县| 富平县| 浪卡子县| 尉犁县|