Solved

constantly scrolling onPress

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now