Jump to content
GreenSock

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

SplitTextField - Get Current Characters Properties

Recommended Posts

Hi there, is is possible to retrieve the current character being tweened as part of a SplitTextField timeline animation?

 

Essentially I'm using it to simulate some text being typed out and I would like a separate object (the cursor) to follow the last character alpha'd in.

 

 

Perhaps I can get this form the onUpdate ?

 

Sample code below :

 

_AnimationTimeline.append(TweenMax.allFrom(stf.textFields, 2, {autoAlpha:0, onUpdate:moveCursor, onUpdateParams:[ "pass the current character here" ]}, 0.06));
 
 
 
function moveCursor () : void {
 
//// reposition the cursor based on the current characters XPos ???
 
}
 
Thanks in advance.
Link to post
Share on other sites

in order to get the x, y, width and height of the character being animated I would use a loop like this:

 


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


var stf:SplitTextField = new SplitTextField(sample_txt);

cursor_mc.alpha = 0.5;

var tl = new TimelineLite();
for (var i:int = stf.textFields.length - 1; i > -1; i--) {
var txt = stf.textFields[i];
tl.set(cursor_mc, {width:txt.width, height:txt.height, x:txt.x + sample_txt.x, y:txt.y  + sample_txt.y}, i * 1); 
tl.from(txt, 2, {alpha:0}, i * 1)
}

Feel free to offset the values to make it look the way you want.

 

Currently that code will size and place the cursor to overlay the current character being animated. Preview: http://greensock.com/forums-support-files/cursor.swf

 

http://greensock.com/forums-support-files/cursor.swf

 

Be sure you are using v12 of GSAP. append() and allFrom() have been deprecated. 

Best to read the TimelineLite docs to see the new methods available. http://greensock.com/asdocs/com/greensock/TimelineLite.html

 

Attached is a CC 2014 fla

cursor_2014cc-fla.zip

  • Like 1
Link to post
Share on other sites

Great! You're welcome.

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.

×