Показать сообщение отдельно
Старый 17.07.2010, 20:08
mayakwd вне форума Посмотреть профиль Отправить личное сообщение для mayakwd Посетить домашнюю страницу mayakwd Найти все сообщения от mayakwd
  № 6  
Ответить с цитированием
mayakwd
 
Аватар для mayakwd

Регистрация: Jul 2008
Адрес: t:2, x: 0.76
Сообщений: 553
Отправить сообщение для mayakwd с помощью ICQ Отправить сообщение для mayakwd с помощью Skype™
UIScrollBar можно подключить к чему угодно.

@see ScrollEvent, UIScrollBar, ScrollPane

Вот вам наглядный пример без ScrollPane:
Код AS3:
package {
	import fl.events.ScrollEvent;
	import fl.controls.UIScrollBar;
 
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.geom.Rectangle;
 
	/**
	 * @author Ilya Malanin (designer@pastila.org)
	 */
	public class Test extends Sprite {
		public static const ITEMS_COUNT : uint = 5;
 
		private var scroll : UIScrollBar;
		private var container : Sprite; 
 
		public function Test() {
			container = new Sprite();
			container.scrollRect = new Rectangle(0, 0, 100, 300);
			container.x = 20;
			container.y = 20;
			addChild(container);
 
			var i : uint = ITEMS_COUNT;
			var maxY : Number = 0;
			while (i--) {
				var shape : Shape = new Shape();
				with (shape.graphics) {
					beginFill(Math.random() * uint.MAX_VALUE, 1);
					drawRect(0, 0, 100, 100);
					endFill();
				}
				shape.y = maxY;
				container.addChild(shape);
 
				maxY += shape.height;
			}
 
			scroll = new UIScrollBar();
			scroll.addEventListener(ScrollEvent.SCROLL, scrollEventHandler);
			scroll.maxScrollPosition = Math.max(maxY - 300, 0); // = container.contentHeight - container.height;
			scroll.setSize(16, 300);
			scroll.x = container.x + 100;
			scroll.y = container.y;
			addChild(scroll); 
		}
 
		private function scrollEventHandler(event : ScrollEvent) : void {
			setContainerScrollPosition(event.position);
		}
 
		private function setContainerScrollPosition(position : Number) : void {
			var rect : Rectangle = container.scrollRect;
			rect.y = position;
			container.scrollRect = rect; 
		}
	}
}
__________________
Блог, Twitter
Брюзга.