Jump to content
Search Community

getting confised with split text field

jimeast test
Moderator Tag

Recommended Posts

I have a page I'm putting together that has a stf embedded in it. http://jimslounge.com/segovia/

I almost have it working the way I want. I have the stf code wrapped in a timer and things don't sync quite right.

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.text.*;
import com.greensock.text.SplitTextField;

var segovia_stf:SplitTextField; 
var myTextLoader:URLLoader = new URLLoader();

myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

var myTimer:Timer = new Timer(9000);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener (e:TimerEvent):void{

runText();
}

myTimer.start();


function onLoaded(e:Event):void {
segovia_mc.segovia_txt.text = e.target.data;
segovia_stf = new SplitTextField(segovia_mc.segovia_txt);
}
function runText():void{
		segovia_mc.y -=110;
		if(segovia_mc.y < -330){segovia_mc.y=0;}

	for (var i:int = segovia_stf.textFields.length - 1; i > -1; i--) {
		TweenMax.to(segovia_stf.textFields[i], 1, {blurFilter:{blurX:10, blurY:10},
		x:Math.random() * 650 - 100, y:Math.random() * 350 - 100,
		scaleX:Math.random() * 4 - 2, scaleY:Math.random() * 4 - 2,
		rotation:Math.random() * 360 - 180, autoAlpha:0,
		delay:Math.random() * 0.4, ease:Quad.easeIn, repeat:1, yoyo:true, repeatDelay:0.2});
	}
}
myTextLoader.load(new URLRequest("myText.txt"));

 

Any suggestions will be greatly appreciated.

Link to comment
Share on other sites

the problem was that you were immediately changing the y value of the clip that holds all the text and then you had a bunch of tweens that all had delays on them start running

 

so there was a brief moment where the text block would move up and then it would animate character by character.

 

the solution is to start all the tweens with no delay and then slide the block of text up.

 

try this:

 

function runText():void {

//don't shift the text until after the tweens have begun
TweenLite.delayedCall(.1, shiftText);

for (var i:int = segovia_stf.textFields.length - 1; i > -1; i--) {

	//remove the delay property from this tween
	TweenMax.to(segovia_stf.textFields[i], 1, {blurFilter:{blurX:10, blurY:10},
	x:Math.random() * 650 - 100, y:Math.random() * 350 - 100,
	scaleX:Math.random() * 4 - 2, scaleY:Math.random() * 4 - 2,
	rotation:Math.random() * 360 - 180, autoAlpha:0, ease:Quad.easeIn, repeat:1, yoyo:true, repeatDelay:0.2});
}
}

function shiftText() {
segovia_mc.y -=  110;
if (segovia_mc.y 		segovia_mc.y = 0;
}
}

Link to comment
Share on other sites

That did it! thanks

I only have one problem left that's that on the first run it doesn't display the last few lines of text. I'm pretty sure I can fix it but if you spot the problem right off and can show me the fix that would be appreciated as I am lazy.

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.
×
×
  • Create New...