Tag Archives: ScrollPane

ScrollPane

ScrollPane内に表示オブジェクトをaddChildすると、ScrollPaneよりオブジェクトが大きかった場合に動的にスクロールバーを表示し、ユーザーの任意でオブジェクト全体を閲覧できるようになる。
固定領域にテキスト、画像、動画を表示したい場合などに使うと便利かも

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package{
	import flash.display.*;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import fl.containers.ScrollPane;
	import fl.events.ScrollEvent;
	import fl.controls.ScrollBarDirection;
 
	public class ScrollPaneClass extends Sprite{
		public function ScrollPaneClass(){
			var _ScrollPane:ScrollPane = new ScrollPane();
 
			//samplBoxを作る
			var A_Box:MovieClip = new MovieClip();
			var B_Box:MovieClip = new MovieClip();
 
			drawBox(A_Box, 0xFF0000,240,200);		//
			drawBox(B_Box,0x000000,40,80);			//
 
			function drawBox(box:MovieClip,color:uint,width:uint,height:uint):void {
				box.graphics.beginFill(color, 1);
				box.graphics.drawRect(0, 0, width, height);
				box.graphics.endFill();
			}
 
			//スクロールペイン対象セット
			_ScrollPane.source = A_Box;
 
			//_ScrollPaneサイズ
			_ScrollPane.setSize(255,120);
 
			//移動距離
			_ScrollPane.verticalLineScrollSize=20;
 
			//表示位置
			_ScrollPane.move(40, 30);
 
			_ScrollPane.addEventListener(ScrollEvent.SCROLL, scrollHandler);
			addChild(_ScrollPane);
			_ScrollPane.source.addChild(B_Box);
 
			//垂直スクロール時にイベント取得
			function scrollHandler(event:ScrollEvent):void {
 
			}
		}
	}
 
}