Показать сообщение отдельно
Старый 08.02.2010, 14:01
spacey999 вне форума Посмотреть профиль Отправить личное сообщение для spacey999 Найти все сообщения от spacey999
  № 1  
Ответить с цитированием
spacey999

Регистрация: Feb 2010
Сообщений: 1
По умолчанию горизонтальный скролл

Люди помогите, скачал прикольный горизонтальный скролл полностью на AS, как присоединить любой другой дизайн к полосе прокрутки?

Код AS1/AS2:
import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var myGalleryXML = new XML();
myGalleryXML.ignoreWhite = true;
myGalleryXML.load("gallery.xml");
 
myGalleryXML.onLoad = function() {
 
	_root.gallery_width = myGalleryXML.firstChild.attributes.width;
	_root.gallery_height = myGalleryXML.firstChild.attributes.height;
	_root.gallery_y = myGalleryXML.firstChild.attributes.y;
 
	_root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing;
	_root.bar_y = Number(_root.gallery_height)+Number(_root.spacing);
	_root.bar_thickness = myGalleryXML.firstChild.attributes.bar_thickness;
	_root.scroller_width = _root.bar_thickness*2;
 
	_root.image_width = myGalleryXML.firstChild.attributes.image_width;
 
	_root.myImages = myGalleryXML.firstChild.childNodes;
	_root.myImagesTotal = _root.myImages.length;
 
	createContainer();
	callImages();
	masking();
	scrollbar();
	scroller();
 
};
 
function createContainer() {
	_root.myGallery_mc = _root.createEmptyMovieClip("myGallery_mc", _root.getNextHighestDepth());
	_root.myGallery_mc._y = _root.gallery_y;
	_root.myGallery_mc._x = (Stage.width-_root.gallery_width)/2;
 
}
 
function callImages() {
 
	_root.myImages_mc = _root.myGallery_mc.createEmptyMovieClip("myImages_mc", _root.myGallery_mc.getNextHighestDepth());
 
	var myMCL:MovieClipLoader = new MovieClipLoader();
 
	for (i=0; i<_root.myImagesTotal; i++) {
		imageURL = _root.myImages[i].attributes.url;
		image_mc = _root.myImages_mc.createEmptyMovieClip(i, _root.myImages_mc.getNextHighestDepth());
		image_mc._x = _root.image_width*i;
 
		myMCL.loadClip(imageURL,image_mc);
	}
 
}
 
function masking() {
	_root.myMask_mc = _root.myGallery_mc.createEmptyMovieClip("myMask_mc", _root.myGallery_mc.getNextHighestDepth());
 
	_root.myMask_mc.beginFill(0x000000,100);
	_root.myMask_mc.lineTo(_root.gallery_width,0);
	_root.myMask_mc.lineTo(_root.gallery_width,_root.gallery_height);
	_root.myMask_mc.lineTo(0,_root.gallery_height);
	_root.myMask_mc.lineTo(0,0);
	_root.myMask_mc.endFill();
 
	_root.myImages_mc.setMask(_root.myMask_mc);
 
}
 
function scrollbar() {
	_root.scrollbar_mc = _root.myGallery_mc.createEmptyMovieClip("scrollbar_mc", _root.myGallery_mc.getNextHighestDepth());
	_root.scrollbar_mc._y = _root.bar_y;
 
	_root.scrollbar_mc.beginFill(0x000000,100);
	_root.scrollbar_mc.lineTo(gallery_width,0);
	_root.scrollbar_mc.lineTo(gallery_width,_root.bar_thickness);
	_root.scrollbar_mc.lineTo(0,_root.bar_thickness);
	_root.scrollbar_mc.lineTo(0,0);
	_root.scrollbar_mc.endFill();
 
	_root.scrollbar_mc.onPress = function() {
		_root.scroller_mc._x = this._xmouse;
 
		if (_root.scroller_mc._x>(this._width-_root.scroller_mc._width)) {
			_root.scroller_mc._x = this._width-_root.scroller_mc._width;
		}
		mover();
	};
 
}
 
function scroller() {
	_root.scroller_mc = _root.myGallery_mc.createEmptyMovieClip("scroller_mc", _root.myGallery_mc.getNextHighestDepth());
	_root.scroller_mc._y = _root.bar_y;
 
	_root.scroller_mc.beginFill(0xFF0000,100);
	_root.scroller_mc.lineTo(_root.scroller_width,0);
	_root.scroller_mc.lineTo(_root.scroller_width,_root.bar_thickness);
	_root.scroller_mc.lineTo(0,_root.bar_thickness);
	_root.scroller_mc.lineTo(0,0);
	_root.scroller_mc.endFill();
 
	_root.scroller_mc.onPress = function() {
		startDrag(this, false, 0, this._y, _root.scrollbar_mc._width-this._width, this._y);
		moverInterval = setInterval(mover,250);
	};
 
	_root.scroller_mc.onRelease = _root.scroller_mc.onReleaseOutside=function () {
		stopDrag();
		clearInterval(moverInterval);
		mover();
	};
}
 
function mover() {
	var scrollerLocation = _root.scroller_mc._x/(_root.scrollbar_mc._width-_root.scroller_mc._width);
	var galleryLocation = scrollerLocation*(_root.myMask_mc._width-_root.myImages_mc._width);
 
	new Tween(_root.myImages_mc, "_x", Strong.easeOut, _root.myImages_mc._x, galleryLocation, 1.5, true);
}
Вложения
Тип файла: zip oman3d.scrollbar-gallery-end-source.zip (284.6 Кб, 45 просмотров)