Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Dynamic textfield width and same speed

Recommended Posts


I created little AS3 aplication for simulate LED display. User can modyfy xml file to set some parameters like: font size and style, textfield position and size.


I do animation by this code:

	var bannerW1: Number = txt_1.width
	var bannerH1: Number = txt_1.height;
	var banner1: BlitMask = new BlitMask(txt_1, txt_1.x, txt_1.y, bannerW1, bannerH1, true, true, 0x00DDDD00, true);
	banner1.bitmapMode = true;
	var tween1: TweenMax = new TweenMax(txt_1, 9, {
		x: -txt_1.width,
		repeat: -1,
		ease: Linear.easeNone
	var bannerW2: Number = txt_2.width
	var bannerH2: Number = txt_2.height;
	var banner2: BlitMask = new BlitMask(txt_2, txt_2.x, txt_2.y, bannerW2, bannerH2, true, true, 0x00DDDD00, true);
	banner2.bitmapMode = true;
	var tween2: TweenMax = new TweenMax(txt_2, 9, {
		x: -txt_2.width,
		repeat: -1,
		ease: Linear.easeNone

I noticed that scroll speed depense on text field width (longer field = fastes scrool).

Is there any way to set scroll speed constant independently of text field width?








Link to post
Share on other sites

Sure. Right now, you've written your code such that the tween always has a duration of 9 seconds and travels the width of the text (that's why it moves further per second for longer text). You just need to alter your duration accordingly. Pick how many pixels per second you want it to move, and then do the math. Kinda like:

var pixelsPerSecond:Number = 500; //tweak this
var duration:Number = txt_1.width / pixelsPerSecond; //plug this into your tween as the duration. 
  • Like 3
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.