Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-10-2012, 04:07 PM   #1
in3eez
Member
 
Join Date: Oct 2008
Posts: 71
Default 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!
in3eez is offline   Reply With Quote
Old 02-10-2012, 08:11 PM   #2
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,397
Default

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.
[afz]snickelfitz is offline   Reply With Quote
Old 02-10-2012, 08:17 PM   #3
in3eez
Member
 
Join Date: Oct 2008
Posts: 71
Default

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.
in3eez is offline   Reply With Quote
Old 02-10-2012, 09:02 PM   #4
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,397
Default

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.
[afz]snickelfitz is offline   Reply With Quote
Old 02-10-2012, 10:16 PM   #5
in3eez
Member
 
Join Date: Oct 2008
Posts: 71
Default

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.
in3eez is offline   Reply With Quote
Old 02-10-2012, 10:18 PM   #6
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,397
Default

Post the formatted code here within [as] tags.
[afz]snickelfitz is offline   Reply With Quote
Old 02-10-2012, 11:08 PM   #7
in3eez
Member
 
Join Date: Oct 2008
Posts: 71
Default

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);
in3eez is offline   Reply With Quote
Old 02-11-2012, 12:10 AM   #8
in3eez
Member
 
Join Date: Oct 2008
Posts: 71
Default

actually the swf works locally, but when I load the index.html file locally, it doesn't work well.
in3eez is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:07 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.