02-10-2012, 04:07 PM
|
#1
|
|
Member
Join Date: Oct 2008
Posts: 71
|
scrollbar sticking
Hi,
I am loading xml text with my scrollbar.
Everything works great but if I add too much text, the scrollbar "sticks".
It will sort of drag, but you can't really control it and it drags really slow.
Is there a way to fix this?
Thanks!
|
|
|
02-10-2012, 08:11 PM
|
#2
|
|
Senior Member
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 1,887
|
Try using a BlitMask instead of a regular mask. With regard to FP rendering, this reduces the height of the textfield to that of the mask, so it really wouldn't matter how much text is in it.
You'll also get better overall scrolling performance.
|
|
|
02-10-2012, 08:17 PM
|
#3
|
|
Member
Join Date: Oct 2008
Posts: 71
|
Great thanks - is this a bug?
It is only happening on Macs.
The file is Flash Player 9.
It scrolls perfectly until I add in too much text.
|
|
|
02-10-2012, 09:02 PM
|
#4
|
|
Senior Member
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 1,887
|
Doesn't sound like a bug, probably just a limitation in Flash Player.
You might be able to code your way around it, but BlitMask is better for scrolling text anyway.
|
|
|
02-10-2012, 10:16 PM
|
#5
|
|
Member
Join Date: Oct 2008
Posts: 71
|
Thanks again.
I'm trying now to recode everything but if I have to this is really helpful.
The scroller works great locally but not online.
I just can't figure out why.
|
|
|
02-10-2012, 10:18 PM
|
#6
|
|
Senior Member
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 1,887
|
Post the formatted code here within [as] tags.
|
|
|
02-10-2012, 11:08 PM
|
#7
|
|
Member
Join Date: Oct 2008
Posts: 71
|
Code:
import caurina.transitions.*;
function setMax():void {
// Set the yMax variable
yMax = scroller.bg.height - scroller.drag.height;
// If the dragger y psition is greater that the current max
if (scroller.drag.y >= yMax) {
// Set the y position
scroller.drag.y = yMax;
}
// If the height of the main_content is less than the mask height
if (contentHeight < contentMask.height) {
// Set the y position of the drag & main_content
Tweener.addTween(scroller.drag, {y:yMin, time:.5, transition:"easeOutExpo"});
Tweener.addTween(main_content, {y:0, time:.5, transition:"easeOutExpo"});
// Set the alpha of the scroller
Tweener.addTween(scroller, {alpha:0, time:0, transition:"easeOutExpo"});
// Set the button mode of the drag
scroller.drag.buttonMode = false;
// If the height of the main_content is more than the mask height
} else {
// Set the alpha of the scroller
Tweener.addTween(scroller, {alpha:1, time:0, transition:"easeOutExpo"});
// Set the button mode of the drag
scroller.drag.buttonMode = true;
}
}
function adjustDragger(position:Number = 0):void {
// If the height of the main_content is less than the mask height
if (contentHeight > contentMask.height) {
// Set the alpha of the scroller
Tweener.addTween(scroller, {alpha:1, time:.5, transition:"easeOutExpo"});
// Set the button mode of the drag
scroller.drag.buttonMode = true;
// If the height of the main_content is more than the mask height
} else {
// Set the alpha of the scroller
Tweener.addTween(scroller, {alpha:0, time:.5, transition:"easeOutExpo"});
// Set the button mode of the drag
scroller.drag.buttonMode = false;
}
// Create variables
var currContentPos:Number = main_content.y;
var newContentPos:Number = -position;
// If the new y position is less than the min
if (newContentPos < -(contentHeight-contentMask.height)) {
// Set the ypos as the min
newContentPos = -(contentHeight-contentMask.height);
}
// If the new y position is greater than the max
if (newContentPos > 0) {
// Set the ypos as the max
newContentPos = 0;
}
// Tween the content to the new y position
Tweener.addTween(main_content, {y:newContentPos, time:.5, transition:"easeOutExpo"});
// Create a variable for the new position of the dragger
var newDraggerPos:Number = yMax * (-newContentPos/(contentHeight-contentMask.height));
// Tween the dragger position
Tweener.addTween(scroller.drag, {y:newDraggerPos,time:.5, transition:"easeOutExpo"});
}
function dragDown(e:MouseEvent):void {
// Set the variables
selectToggle = true;
yOffset = mouseY - scroller.drag.y;
// Add event listeners to the stage
stage.addEventListener(MouseEvent.MOUSE_UP, dragUp);
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragMove);
}
function dragUp(e:MouseEvent):void {
// If selectToggle is true
if (selectToggle == true) {
// Set the toggle to false
selectToggle = false;
// Remove the event listener
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragMove);
}
}
function dragMove(e:MouseEvent):void {
// If the content height is greater than the mask height
if (contentHeight > contentMask.height) {
// Set the ypos of the drag
scroller.drag.y = mouseY - yOffset;
if (scroller.drag.y <= yMin) {
scroller.drag.y = yMin;
}
if (scroller.drag.y >= yMax) {
scroller.drag.y = yMax;
}
// Save a variable for the amount to move the content
var moved:Number = scroller.drag.y / yMax;
// Tween the content of the scroller
Tweener.addTween(main_content, {y:(-moved*(contentHeight-contentMask.height)), time:.5, transition:"easeOutExpo"});
}
}
function scrollOver(e:MouseEvent):void {
// If the mousewheel is enabled
if (mouseWheelToggle == true){
// Add an event listener
home.addEventListener(MouseEvent.MOUSE_WHEEL, viewerWheel);
}
}
function viewerWheel(e:MouseEvent):void {
// If the mousewheel is enabled
if (mouseWheelToggle == true){
// If the content height is greater than the mask height
if (contentHeight > contentMask.height) {
// Set the ypos of the drag
scroller.drag.y = scroller.drag.y - ((scroller.height/scroller.drag.height) * e.delta);
if (scroller.drag.y <= yMin) {
scroller.drag.y = yMin;
}
if (scroller.drag.y >= yMax) {
scroller.drag.y = yMax;
}
// Save a variable for the amount to move the content
var moved:Number = scroller.drag.y / yMax;
// Tween the content of the scroller
Tweener.addTween(main_content, {y:(-moved*(contentHeight-contentMask.height)), time:.5, transition:"easeOutExpo"});
}
}
}
var home:MovieClip = this;
var yOffset:Number;
var yMin:Number = 0;
var yMax:Number = scroller.bg.height - scroller.drag.height;
var selectToggle:Boolean;
var contentHeight:Number = main_content.height;
var mouseWheelToggle:Boolean = true;
this.mouseEnabled = false;
scroller.mouseEnabled = false;
scroller.drag.mouseEnabled = true;
scroller.drag.buttonMode = true;
home.addEventListener(MouseEvent.MOUSE_OVER, scrollOver);
scroller.drag.addEventListener(MouseEvent.MOUSE_DOWN, dragDown);
|
|
|
02-11-2012, 12:10 AM
|
#8
|
|
Member
Join Date: Oct 2008
Posts: 71
|
actually the swf works locally, but when I load the index.html file locally, it doesn't work well.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 01:53 AM.
///
|
|