国产探花免费观看_亚洲丰满少妇自慰呻吟_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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 卓资县| 巨野县| 百色市| 呼图壁县| 麻栗坡县| 得荣县| 巴东县| 温宿县| 乌兰浩特市| 集安市| 远安县| 红河县| 合肥市| 屏山县| 明星| 高清| 高平市| 噶尔县| 松溪县| 景泰县| 博野县| 象州县| 德兴市| 麦盖提县| 荔浦县| 鄂尔多斯市| 常宁市| 呼伦贝尔市| 浠水县| 龙州县| 高唐县| 左贡县| 洛扎县| 定陶县| 深水埗区| 湄潭县| 玉环县| 怀化市| 黎城县| 中江县| 华池县|