RolfDingerink
%Europe/Berlin %636 %2007, 16:16
een heel aantal mc's van een website die ik maak gebruiken het volgende script voor scroll..
nu gaat de scroll telkens als ik een nieuw item open steeds sneller.. net of de snelheid bij elkaar wordt opgeteld.
wie weet hoe ik dit kan oplossen?
import flash.geom.*;
import flash.filters.*;
txtHeight = bg._height-mc._y*2;
re = new Rectangle(0, 0, mc._width+5, txtHeight+3);
mc.scrollRect = re;
//
txt = mc.txt;
txt.speed = 0;
txt.filters = new Array(new BlurFilter(0, 0, 1));
//
obj = new Object();
Mouse.addListener(obj);
obj.onMouseWheel = function(v) {
if (txt._y != 0 || txt._y != -(txt._height-txtHeight)) {
txt.speed += v*3;
} else {
txt.speed = 0;
}
};
onEnterFrame = function () {
txt.speed *= .8;
txt._y += txt.speed;
//
if (txt._y>0) { txt._y = 0;
txt.speed = 0;
} else if (txt._y<=-(txt._height-txtHeight)) {
txt._y = -(txt._height-txtHeight);
txt.speed = 0;
}
//
if (txt._y == 0 || txt._y == -(txt._height-txtHeight)) {
temp = txt.filters[0];
temp.blurY -= (temp.blurY>0) ? 5 : 0;
txt.filters = new Array(temp);
} else { temp = txt.filters[0];
temp.blurY = Math.abs(txt.speed/2);
txt.filters = new Array(temp);
}
};
scrolling = function () {
var scrollHeight:Number = scrollTrack._height;
var contentHeight:Number = mc.txt._height;
var scrollFaceHeight:Number = scrollFace._height;
var maskHeight:Number = bg._height;
var initPosition:Number = scrollFace._y=scrollTrack._y;
var initContentPos:Number = mc.txt._y;
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
var left:Number = scrollTrack._x;
var top:Number = scrollTrack._y;
var right:Number = scrollTrack._x;
var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._y;
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
scrollFace.onPress = function() {
var currPos:Number = this._y;
startDrag(this, false, left, top, right, bottom);
this.onMouseMove = function() {
dy = Math.abs(initPosition-this._y);
mc.txt._y = Math.round(dy*-1*moveVal+initContentPos);
};
};
scrollFace.onMouseUp = function() {
stopDrag();
delete this.onMouseMove;
};
btnUp.onPress = function() {
this.onEnterFrame = function() {
if (mc.txt._y+speed<bg._y) {
if (scrollFace._y<=top) {
scrollFace._y = top;
} else {
scrollFace._y -= speed/moveVal;
}
mc.txt._y += speed;
} else {
scrollFace._y = top;
mc.txt._y = bg._y;
delete this.onEnterFrame;
}
};
};
btnUp.onRelease = function() {
delete this.onEnterFrame;
};
btnUp.onDragOut = function() {
delete this.onEnterFrame;
};
btnUp.onRollOut = function() {
delete this.onEnterFrame;
};
btnDown.onPress = function() {
this.onEnterFrame = function() {
if (mc.txt._y-speed>finalContentPos) {
if (scrollFace._y>=bottom) {
scrollFace._y = bottom;
} else {
scrollFace._y += speed/moveVal;
}
mc.txt._y -= speed;
} else {
scrollFace._y = bottom;
mc.txt._y = finalContentPos;
delete this.onEnterFrame;
}
};
};
btnDown.onRelease = function() {
delete this.onEnterFrame;
};
btnDown.onDragOut = function() {
delete this.onEnterFrame;
};
if (contentHeight<maskHeight) {
scrollFace._visible = false;
btnUp.enabled = false;
btnDown.enabled = false;
} else {
scrollFace._visible = true;
btnUp.enabled = true;
btnDown.enabled = true;
}
};
scrolling();
http://www.aktieshirts.nl/test2
nu gaat de scroll telkens als ik een nieuw item open steeds sneller.. net of de snelheid bij elkaar wordt opgeteld.
wie weet hoe ik dit kan oplossen?
import flash.geom.*;
import flash.filters.*;
txtHeight = bg._height-mc._y*2;
re = new Rectangle(0, 0, mc._width+5, txtHeight+3);
mc.scrollRect = re;
//
txt = mc.txt;
txt.speed = 0;
txt.filters = new Array(new BlurFilter(0, 0, 1));
//
obj = new Object();
Mouse.addListener(obj);
obj.onMouseWheel = function(v) {
if (txt._y != 0 || txt._y != -(txt._height-txtHeight)) {
txt.speed += v*3;
} else {
txt.speed = 0;
}
};
onEnterFrame = function () {
txt.speed *= .8;
txt._y += txt.speed;
//
if (txt._y>0) { txt._y = 0;
txt.speed = 0;
} else if (txt._y<=-(txt._height-txtHeight)) {
txt._y = -(txt._height-txtHeight);
txt.speed = 0;
}
//
if (txt._y == 0 || txt._y == -(txt._height-txtHeight)) {
temp = txt.filters[0];
temp.blurY -= (temp.blurY>0) ? 5 : 0;
txt.filters = new Array(temp);
} else { temp = txt.filters[0];
temp.blurY = Math.abs(txt.speed/2);
txt.filters = new Array(temp);
}
};
scrolling = function () {
var scrollHeight:Number = scrollTrack._height;
var contentHeight:Number = mc.txt._height;
var scrollFaceHeight:Number = scrollFace._height;
var maskHeight:Number = bg._height;
var initPosition:Number = scrollFace._y=scrollTrack._y;
var initContentPos:Number = mc.txt._y;
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
var left:Number = scrollTrack._x;
var top:Number = scrollTrack._y;
var right:Number = scrollTrack._x;
var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._y;
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
scrollFace.onPress = function() {
var currPos:Number = this._y;
startDrag(this, false, left, top, right, bottom);
this.onMouseMove = function() {
dy = Math.abs(initPosition-this._y);
mc.txt._y = Math.round(dy*-1*moveVal+initContentPos);
};
};
scrollFace.onMouseUp = function() {
stopDrag();
delete this.onMouseMove;
};
btnUp.onPress = function() {
this.onEnterFrame = function() {
if (mc.txt._y+speed<bg._y) {
if (scrollFace._y<=top) {
scrollFace._y = top;
} else {
scrollFace._y -= speed/moveVal;
}
mc.txt._y += speed;
} else {
scrollFace._y = top;
mc.txt._y = bg._y;
delete this.onEnterFrame;
}
};
};
btnUp.onRelease = function() {
delete this.onEnterFrame;
};
btnUp.onDragOut = function() {
delete this.onEnterFrame;
};
btnUp.onRollOut = function() {
delete this.onEnterFrame;
};
btnDown.onPress = function() {
this.onEnterFrame = function() {
if (mc.txt._y-speed>finalContentPos) {
if (scrollFace._y>=bottom) {
scrollFace._y = bottom;
} else {
scrollFace._y += speed/moveVal;
}
mc.txt._y -= speed;
} else {
scrollFace._y = bottom;
mc.txt._y = finalContentPos;
delete this.onEnterFrame;
}
};
};
btnDown.onRelease = function() {
delete this.onEnterFrame;
};
btnDown.onDragOut = function() {
delete this.onEnterFrame;
};
if (contentHeight<maskHeight) {
scrollFace._visible = false;
btnUp.enabled = false;
btnDown.enabled = false;
} else {
scrollFace._visible = true;
btnUp.enabled = true;
btnDown.enabled = true;
}
};
scrolling();
http://www.aktieshirts.nl/test2