PDA

Просмотр полной версии : скроллер xml текста и мышь


dream'r
20.11.2008, 16:15
Здравствуйте. У меня есть текст, читаемый из xml. бегунок если двигать то текст прокручивается нормально. если колесом - текст движется, а бегунок нет.
function scrollInit(tt, ts) {
// ts.bar._y = tt._y;
if (tt.maxscroll>1) {//if no need, hide scrolling
ts.scrollarea = ts._height-ts.uparrow._height-ts.dnarrow._height;
ts.bar._height = ts.scrollarea-((tt.maxscroll-1)*10);
ts.rel = (ts.scrollarea-ts.bar._height)/(tt.maxscroll-1);
ts.bar._y = ts.rel*tt.scroll+ts.uparrow._height-ts.rel;
ts._visible = true;
//buttons scrolling
ts.dnarrow.onPress = function() {
ts.onEnterFrame = function() {
if (tt.scroll<tt.maxscroll) {
tt.scroll++;
ts.bar._y = ts.rel*tt.scroll+ts.uparrow._height-ts.rel;
}
};
};
//////////////////////////
ts.bar.originY = ts.bar._y;
ts.bar.originX = ts.bar._x;
ts.bar.maxY = ts.bar._height-ts.bar._height+ts.bar.originY-1;
tt.originY = tt._y;
//////////////////
ts.dnarrow.onRelease = ts.dnarrow.onReleaseOutside = function () {
delete ts.onEnterFrame;
};
ts.uparrow.onPress = function() {
ts.onEnterFrame = function() {
if (tt.scroll>1) {
tt.scroll--;
ts.bar._y = ts.rel*tt.scroll+ts.uparrow._height-ts.rel;
}
};
};
ts.uparrow.onRelease = ts.uparrow.onReleaseOutside = function () {
delete ts.onEnterFrame;
};
//bar scrolling
ts.bar.onPress = function() {
startDrag(ts.bar, false, 0, ts.uparrow._height, 0, ts.scrollarea+ts.uparrow._height-this._height+1);
ts.bar.draging = true;
};
ts.bar.onRelease = ts.bar.onReleaseOutside = function () {
ts.bar.stopDrag();
ts.bar.draging = false;
};
ts.bar.onMouseMove = function() {
if (ts.bar.draging) {
tt.scroll = (ts.bar._y-ts.uparrow._height+ts.rel)/ts.rel;
}
};
ts.bar.onMouseWheel = function() {
if (ts.bar.draging) {
tt.scroll = (ts.bar._y-ts.uparrow._height+ts.rel)/ts.rel;
}
};
} else {
ts._visible = false;
}
}
// WHEEL MOUSE LISTENER
//
var mouseListener:Object = new Object(this);
mouseListener.onMouseWheel = function(wheelNum:Number) {
if (ts.bar._y>=ts.bar.originY) {
ts.bar._y -= (wheelNum/scrollRatio)*8;
if (ts.bar._y<ts.bar.originY) {
ts.bar._y = ts.bar.originY;
} else if (ts.bar._y>ts.bar.originY+ts.bot._height-ts.bar._height) {
ts.bar._y = ts.bar.originY+ts.bot._height-ts.bar._height;
}
}
if (ts.bar._y>ts.bar.maxY) {
ts.bar._y = ts.bar.maxY;
}
};
Mouse.addListener(mouseListener);
// SCROLL BAR SCRIPT
onEnterFrame = function () {
scrollRatio = (tt._height-200)/ts.bot._height;
if (scrollRatio>1) {
// Show scroll bar
ts.bar._visible = true;
ratio = ((tt._height-200)-ts.bot._height)/(ts.bot._height-ts.bar._height);
destScroll = ((-ts.bar._y+tt.originY)*ratio)+tt.originY;
tt._y += Math.ceil((destScroll-tt._y)/4);
} else {
// Hide scroll bar
ts.bar._visible = false;
}
};
stop();
срабатывание вызывается вот так
this.scrollInit(opisanie.o_text.opisanie_txt,this.opisanie.myScroll);
----
подскажите пожалуйста как мне сделать чтобы прокручивая колесом мыши текст, двигался и бегунок...

Mnilionic
20.11.2008, 17:14
tt.onScroller

dream'r
20.11.2008, 18:21
tt.onScroller

я не очень понял к чему это... ;(

Wolsh
20.11.2008, 18:37
http://flasher.ru/forum/showthread.php?t=111891
Впрочем, если этот код Вы сами написали, то Вам хватит и этого: http://www.flasher.ru/forum/showpost.php?p=746848&postcount=6
Удачи

Mnilionic
20.11.2008, 19:17
dream'r, у вас видимо сделана зависимость скролинга текста от положения бегунка.
теперь нужно сделать оратную зависимость - полжение пегунка от скролинга текста.

событие onScroller вызывается всякий раз как в поле меняется одно из значений скролинга текста. По этому собитию передвигайте ваш ползунок на нужное значение.

например если вы в поле будите выделать текст мышкой (ткнёте мышкой в начале текста и потяните вниз за границу поля, то текст будет скролится за мышкой) ползунок будет в правильном положении