We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Actionscript 2.0 text ticker

alecda
alecda asked
on
Medium Priority
915 Views
Last Modified: 2013-11-11
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

Comment
Watch Question

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

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

Author

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

Alec
ok

use the hscroll method

GE


Author

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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.