Solved

constantly scrolling onPress

Posted on 2007-11-27
3
215 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

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!

Question has a verified solution.

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

Suggested Solutions

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

685 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