I’m running into some problems with math.round not working how I’d like it to work. I’m using a pixel font, and if the text does not land on a whole pixel, it becomes blurry. I suspect it might be an easy fixed to the trained eye so I’ve posted the script. Thanks!
[AS]
function setDragMask() {
ts.dragger.onPress = function() {
this.released = false;
startDrag(this, false, this._x, 0, this._x, ts.theMask._height-this._height);
// The scrolling animation
ts.theText.onEnterFrame = function() {
trace("enterframe");
scrollAmount = (this._height - (ts.theMask._height/1.3))/(ts.theMask._height - ts.dragger._height);
ts.dragger._height = 30;
// Set a new target y position
targY = -ts.dragger._y*scrollAmount;
Math.round()(this._y -= Math.round((this._y-targY)/5));
this._y -= (this._y-targY)/5;
trace(Math.abs(this._y)+' = '+Math.abs(targY));
trace(Math.abs(this._y)+'<='+Math.abs(targY+1)+'&&'+Math.abs(this._y)+'>='+Math.abs(targY-1));
if ( (Math.abs(this._y)<=Math.abs(targY)+1)&&(Math.abs(this._y)>=Math.abs(targY)-1)) {
trace('inside');
if(ts.dragger.released == true) {
trace('delete');
delete this.onEnterFrame;
}
}
}
}
Does this look better? I tried it and it seems to work, but the scrolling isn’t as smooth any more. I’m wondering if that’s just the compromise for forcing it on a whole pixel?
[AS]
// --------------------------------------------------------------------------------------
function setDragMask() {
ts.dragger.onPress = function() {
this.released = false;
startDrag(this, false, this._x, 0, this._x, ts.theMask._height-this._height);
// The scrolling animation
ts.theText.onEnterFrame = function() {
trace("enterframe");
scrollAmount = (this._height - (ts.theMask._height/1.3))/(ts.theMask._height - ts.dragger._height);
// Adjust the height of the dragger to reflect the amount of content available to see
ts.dragger._height = 30;
// Set a new target y position
targY = -ts.dragger._y*scrollAmount;
Math.round(this._y -= Math.round((this._y-targY)/5));
this._y -= Math.round((this._y-targY)/5);
That makes sense, because it makes no difference if I take Math.round out of that line and run the script. So what do you think would make this thing not blurry font? :toad:
ts.dragger.onPress = function() {
this.released = false;
startDrag(this, false, this._x, 0, this._x, ts.theMask._height-this._height);
// The scrolling animation
ts.theText.y = ts.theText._y; // <<---------------new
ts.theText.onEnterFrame = function() {
trace(“enterframe”);
scrollAmount = (this._height - (ts.theMask._height/1.3))/(ts.theMask._height - ts.dragger._height);
// Adjust the height of the dragger to reflect the amount of content available to see
ts.dragger._height = 30;
// Set a new target y position
targY = -ts.dragger._y*scrollAmount;
this.y -= (this.y-targY)/5; // <<---------------new