[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

constantly scrolling onPress

Hello, does anyone know how to create a scroll button that constantly scrolls when pressed as opposed to advancing one increment per click??

I'm only using this at the mo.

this.scroller.down_btn.onPress= function() {
    paraOne.scroll += 1;
};

this.scroller.up_btn.onPress = function() {
    paraOne.scroll -= 1;
};


Cheers, Paul.
0
Sideas
Asked:
Sideas
  • 2
2 Solutions
 
CyanBlueCommented:
What you define within the onPress handler executes only once...  So, you will need additional loop to execute the constant scrolling...

Try something like this...

CyanBlue
this.scroller.down_btn.onPress = function()
{
	delete this._parent.onEnterFrame;
	this._parent.onEnterFrame = function ()
	{
		paraOne.scroll += 1;
	}
}
this.scroller.up_btn.onPress = function()
{
	delete this._parent.onEnterFrame;
	this._parent.onEnterFrame = function ()
	{
		paraOne.scroll -= 1;
	}
}

Open in new window

0
 
SideasAuthor Commented:
Cheers CyanBlue that does work, but it jumps the scroll box down way too quick.

Do you know of a way of putting some, I dunno "weight" or "time" into a scroll?

Cheers, P.
0
 
CyanBlueCommented:
You could use setInterval() function instead of the onEnterFrame handler...

CyanBlue
var scrollSpeed:Number = 250;
// 1000 is 1 second for scrollSpeed value...
//
this.scroller.down_btn.onPress = function()
{
	_global.scroll_iv = setInterval(scrollParagraph, scrollSpeed, 1);
}
this.scroller.down_btn.onRelease = function()
{
	clearInterval(_global.scroll_iv);
}
//
this.scroller.up_btn.onPress = function()
{
	_global.scroll_iv = setInterval(scrollParagraph, scrollSpeed, -1);
}
this.scroller.up_btn.onRelease = function()
{
	clearInterval(_global.scroll_iv);
}
//
function scrollParagraph(_val:Number)
{
	paraOne.scroll += _val;
}

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now