Solved

constantly scrolling onPress

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

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