画面表示 - スクロール
スクロール位置の取得・設定
スクロール位置取得はDisplayObject.getScrollPosメソッド、スクロール位置の設定はDisplayObject.setScrollPosメソッドで行うことができます。
サンプルコードでは、Formのスクロール位置とNumberEdit.Valueプロパティを
同期させています。
・Formのスクロール位置をNumberEditに表示
・NumberEditに表示された数値にFormのスクロール位置を移動
Form ScD0132 { x = 0; y = 0; width = 444; height = 527; Form form1 { x = 25; y = 25; width = 226; height = 477; Label label1[20] { x = 9; y = 8; width = 270; height = 30; bgColor = new Brush("#ff55aaff", Brush.DENSE1); layoutSpacing = 2; horizontalAlign = ALIGN_CENTER; font = new Font("",20); value &= index + 1; } Function onScrolled(e){ /* 横スクロール位置の取得 */ ^.horScrollPos.value = this.getScrollPos(DisplayObject.SCROLL_HORIZONTAL); /* 縦スクロール位置の取得 */ ^.verScrollPos.value = this.getScrollPos(DisplayObject.SCROLL_VERTICAL); } } /* 横スクロール */ NumberEdit horScrollPos { x = 332; y = 30; width = 96; height = 35; margin = 5; font = new Font("MS UI Gothic", 16); useChange = true; Function onChange(e){ try{ /* 横スクロール位置の設定 */ ^.form1.setScrollPos(e.from.value,DisplayObject.SCROLL_HORIZONTAL); }catch(e){ print(e); } } } /* 縦スクロール */ NumberEdit verScrollPos { x = 332; y = 72; width = 96; height = 35; margin = 5; font = new Font("MS UI Gothic", 16); useChange = true; Function onChange(e){ try{ /* 縦スクロール位置の設定 */ ^.form1.setScrollPos(e.from.value,DisplayObject.SCROLL_VERTICAL); }catch(e){ print(e); } } } Label label1 { x = 279; y = 30; width = 49; height = 35; value = "横位置"; verticalAlign = ALIGN_MIDDLE; } Label label2 { x = 279; y = 72; width = 49; height = 35; value = "縦位置"; verticalAlign = ALIGN_MIDDLE; } }
Biz-Collections Bizの宝箱 トップへ
Biz/Browser DT・Biz/Designer DT TIPS集 トップへ