Solved

constantly scrolling onPress

Posted on 2007-11-27
3
213 Views
Last Modified: 2010-04-03
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
Comment
Question by:Sideas
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
CyanBlue earned 500 total points
ID: 20365689
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
 
LVL 2

Author Comment

by:Sideas
ID: 20380530
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
 
LVL 37

Assisted Solution

by:CyanBlue
CyanBlue earned 500 total points
ID: 20382508
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question