Flash AS2 Scroller
- Started
- Last post
- 5 Responses
- dbsaxton
How would I add easing to this scroller code.
Thanks in advance.#include "mc_tween2.as"
scrolling = function () {
var scrollHeight:Number = scrollTrack._height;
var contentHeight:Number = contentMain._height;
var scrollFaceHeight:Number = scrollFace._height;
var maskHeight:Number = maskedView._height;
var initPosition:Number = scrollFace._y=scrollTrack._y;
var initContentPos:Number = contentMain._y;
var finalContentPos:Number = maskHeight-contentHeight+initCon...
var left:Number = scrollTrack._x;
var top:Number = scrollTrack._y;
var right:Number = scrollTrack._x;
var bottom:Number = scrollTrack._height-scrollFaceHe...
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentHeight-maskHeight)/(scro...
scrollFace._alpha=100scrollFace.onRollOver = function() {
this.alphaTo (50, 1,"easeOutQuart");};
scrollFace.onRollOut = function() {
this.alphaTo (100, 1,"easeOutQuart");};
scrollFace.onPress = function() {
var currPos:Number = this._y;
startDrag(this, false, left, top, right, bottom);
this.onMouseMove = function() {
dy = Math.abs(initPosition-this._y);
contentMain._y = Math.round(dy*-1*moveVal+initCon...
};
};
scrollFace.onMouseUp = function() {
stopDrag();
delete this.onMouseMove;
};
btnUp.onPress = function() {
this.onEnterFrame = function() {
if (contentMain._y+speed<maskedView._y) { if (scrollFace._y<=top) { scrollFace._y = top; } else { scrollFace._y -= speed/moveVal; } contentMain._y += speed; } else { scrollFace._y = top; contentMain._y = maskedView._y; delete this.onEnterFrame; } }; }; btnUp.onDragOut = function() { delete this.onEnterFrame; }; btnUp.onRollOut = function() { delete this.onEnterFrame; }; btnDown.onPress = function() { this.onEnterFrame = function() { if (contentMain._y-speed>finalContentPos) {
if (scrollFace._y>=bottom) {
scrollFace._y = bottom;
} else {
scrollFace._y += speed/moveVal;
}
contentMain._y -= speed;
} else {
scrollFace._y = bottom;
contentMain._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();
- ********0
LOL
- dbsaxton0
Indeed funny
I'm updating a site which has several scrollers coded this way and very short amount of time.
But thanks for the heads up though
- chossy0
Desparatly in need of this as well!! :D weird.
- rounce0
I've got an old AS3 one I did a few years ago that worked quite nice and is fast and smooth (< 20 lines, iirc).
(Rather dodgy imho) example:
http://labs.samuelrounce.co.uk/f…
Sauce:
http://labs.samuelrounce.co.uk/f…If it's useful i can put up an example FLA or write a Class for it when I get home if you want.