Jump to content
GreenSock

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

Dynamic textfield width and same speed

Go to solution Solved by GreenSock,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

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?

 

Best!

Pandik.

 

 

 

 

Link to comment
Share on other sites

  • Solution

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 comment
Share on other sites

Yea, its logical and its works :)

Thanks!

Link to comment
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.
×