tutto il codice
Codice PHP:
if (_root.altezzas > 760) {
this._visible = false;
} else {
this._visible = true;
}
function scrollUpdate() {
var contenuto = _root.tuttoilsito_mc.contenuto;
barra.scrolin_mc._height = _root.altezzas/5
barra.frecce_mc._y = barra.scrolin_mc._height/2
var pxls_cont = contenuto._height-this.bg._height;
var pxls_scroll = this.bg._height-this.barra._height;
var alfa = pxls_cont/pxls_scroll;
var vel = 2;
var desty = -this.barra._y*alfa+this.hxini;
desty = Math.floor(desty);
contenuto._y = Math.floor((contenuto._y*vel+desty)/(vel+1));
}
function starmenuScroll() {
yfin = this._parent.bg._height-this._height;
this.startDrag("", this._x, 0, this._x, yfin);
}
function stopScroll() {
this.stopDrag();
}
function moveScroll(dir) {
if (dir == "stop") {
delete controlador["onEnterFrame"];
} else {
var barra = this.barra;
var vel = 4;
if (dir == "cima") {
var lim = 0;
vel = vel*-1;
} else {
var lim = this.bg._height-barra._height;
}
}
controlador.onEnterFrame = function() {
if (dir == "baixo") {
if (barra._y+vel<lim) {
barra._y = barra._y+vel;
} else {
barra._y = lim;
}
} else if (barra._y+vel>lim) {
barra._y = barra._y+vel;
} else {
barra._y = lim;
}
};
}
this.hxini = this._parent.contenuto._y;
this.onEnterFrame = scrollUpdate;
this.barra.onPress = starmenuScroll;
this.barra.onRelease = stopScroll;
this.barra.onReleaseOutside = stopScroll;
this.createEmptyMovieClip("controlador", 100);
sup.onPress = function() {
moveScroll("cima");
};
sup.onRelease = inf.onRelease=function () {
moveScroll("stop");
};
inf.onPress = function() {
moveScroll("baixo");
};
inf.onRelease = function() {
moveScroll("stop");
};
barra.useHandCursor = true;
sup.useHandCursor = false;
inf.useHandCursor = false;
trace("barray" +barra._y)
// dichiaro il listener per lo scroll
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta) {
delta=delta*5
toty = barra._y + (-delta)
//rotella in giu
if (delta < 0 && barra._y <= bg._height - barra._height - (-delta)) {
if (barra._y = toty) {
moveScroll("stop")
} else {
moveScroll("baixo");
}
}
//rotella in su
if (delta > 0 && barra._y > 0) {
if (barra._y = toty) {
moveScroll("stop")
} else {
moveScroll("cima");
}
}
trace(delta)
};
Mouse.addListener(mouseListener);
var objList = new Object();
objList.onKeyDown = function() {
codbottone = Key.getCode()
trace(Key.getCode());
if (codbottone == 40){
moveScroll("baixo");
}
if (codbottone == 38){
moveScroll("cima");
}
};
Key.addListener(objList);