• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 859
  • Last Modified:

Actionscript 2.0 text ticker

Hello,

I have a dynamic text box I would like to scroll horizontally like a news ticker. Can anyone give me some direction as to doing this? I found some code online that scrolls but doesn't do exactly what I want (which I've included). It moves back and forth from left to right, right to left. I'd like it to continuously move right to left and repeat the text. Would anyone know how to change this code to do that or know of some better code to do what I'm needing it to do.

Thank you,

Alec
var size:Number = 21;
var textPos:Number = 0;
var intervalID:Number = setInterval(scroller, 1000);
var textBody:String = "This is the text I'd like to scroll";
 
 
function scroller():Void{
	
	if(textPos+size < t.length)
	{
		textPos++;
		trackInfo.text = textBody.substring(textPos, textPos+size);
	}
	else 
	{
		clearInterval(intervalID);
		intervalID = setInterval(scroller2, 1000);
	}
}
 
function scroller2():Void{
 
	if(textPos > 0)
	{
		textPos--;
		trackInfo.text = textBody.substring(textPos, size);
	}
	else 
	{
		clearInterval(intervalID);
		intervalID = setInterval(scroller, 1000);
	}
}

Open in new window

0
alecda
Asked:
alecda
  • 3
  • 3
1 Solution
 
Eaddy BarnesITCommented:
please review the following link

http://mrsteel.wordpress.com/2007/02/14/dynamic-text-scrolling-actionscript-example/

please let me know if it help

GE
0
 
alecdaAuthor Commented:
Thanks greeneel, the code works as a ticker, however the text runs off the edge of the screen. I need the text to stay within the text field area. The code just runs out of the text area and off the edge of the screen. Would you happen to know how to apply this code to stay within a specified area?

Alec
onEnterFrame = function() {
	sirina_ = txt_prvi.textWidth;
duplicateMovieClip("txt_prvi", "txt_drugi", this.getNextHighestDepth());
	originalx_ = txt_prvi.x
	
	txt_drugi._x = txt_prvi._x + sirina_ + 5;
	txt_drugi._y = txt_prvi._y;
	txt_prvi._x -= 3;
	txt_drugi._x -= 3;
	if ((txt_prvi._x + sirina_)< 0) { 
		txt_prvi._x = txt_drugi._x-3;
		txt_drugi._x = txt_prvi._x + sirina_ + 5;
	} 
}

Open in new window

0
 
Eaddy BarnesITCommented:
question:

do you want the data to scroll inside the text field by it's self?
or is it that you want the user to scroll the data horizontally?
do you want the data to just scroll across and you don't
see when the data leaves the stage much like what  a mask would do?

GE
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
alecdaAuthor Commented:
Yes, I want the data to scroll inside the text field by it's self. And not to leave the text field.

Alec
0
 
Eaddy BarnesITCommented:
ok

use the hscroll method

GE


0
 
alecdaAuthor Commented:
I'm sorry, I'm not explaining myself clearly.... I need the text to move like a news ticker inside the text box. Not a scroll text box......... The link you sent me was exactly how I want the text to move except I need it to stay inside the text area.

Alec
0

Featured Post

Industry Leaders: 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!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now