Solved

constantly scrolling onPress

Posted on 2007-11-27
3
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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 use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

717 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