Kære alle.
Håber at i kan hjælpe mig med mit problem, Jeg har på en klub side lavet en links side med scroll funktion (baddevil.dk). Mit problem er at jeg gerne ville have wheel scroll med også. Har prøvet med mouseListener.onMouseWheel men kan ikke få det til at fungere sammen, så min scrollbar følger med whellscroll, samt at sætte grænsen for wheelscroll op og ned.
Koden til min scroller er:
onClipEvent (load) {
diff_y = bound_box._height-scroller._height;
bounds = bound_box.getBounds(this);
top = bounds.yMin+(scroller._height/2);
bottom = bounds.yMax-(scroller._height/2);
function updateScrollbar () {
content._y = -(((scroller._y-top)/diff_y)*(content._height-bound_box._height));
}
}
onClipEvent (mouseDown) {
if (scroller.hitTest(_root._xmouse, _root._ymouse)) {
startDrag ("scroller", false, scroller._x, top, scroller._x, bottom);
scrolling = true;
}
}
onClipEvent (mouseUp) {
stopDrag ();
scrolling = false;
}
onClipEvent (enterFrame) {
if (scrolling) {
updateScrollbar();
}
}
Håber at der er nogen der kan hjælpe mig!!! ![]()
1 kommentar
Efter at have rodet en del med det, fandt jeg denne løsning!
onClipEvent (load) {
diff_y = bound_box._height-scroller._height;
bounds = bound_box.getBounds(this);
top = bounds.yMin+(scroller._height/2);
bottom = bounds.yMax-(scroller._height/2);
function updateScrollbar () {
content._y = -(((scroller._y-top)/diff_y)*(content._height-bound_box._height));
}
}
onClipEvent (mouseDown) {
if (scroller.hitTest(_root._xmouse, _root._ymouse)) {
startDrag ("scroller", false, scroller._x, top, scroller._x, bottom);
scrolling = true;
}
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta) {
if (scroller._y > 32.05) {
content._y += delta *3;
scroller._y -=delta;
}
else {
scroller._y = 32.05;
content._y = 13.95;
trace(scroller._y);
trace(content._y);
}
if (content._y > -1597.05) {
content._y += delta *3;
scroller._y -=delta;
}
else {
scroller._y = 572.05;
content._y = -1597.05;
}
}
Mouse.addListener(mouseListener);
}
onClipEvent (mouseUp) {
stopDrag ();
scrolling = false;
}
onClipEvent (enterFrame) {
if (scrolling) {
updateScrollbar();
}
}
De to trace funktioner er kun sat ind for at finde mine bounds.
delta *3 er for at min scroller og content følges ad.