Jump to content
Search Community

reset of the animated textField

Macan_NBGD test
Moderator Tag

Recommended Posts

can anyone please help me - I'm pretty much newbie in scripting and got problem when trying to reset animated value in textField..goal is to make TextField count numbers from zero to 15, and onComplete reset to zero and count again..( thanks in advance)..here's my code:

var form:TextFormat= new TextFormat("Arial", 25, 0);
var fifteen_TF:TextField= new TextField();
fifteen_TF.defaultTextFormat= form;
fifteen_TF.x= fifteen_TF.y= 200;
addChild(fifteen_TF);
var num:int= 0;
function moveNums():void
{
TweenLite.to(this, 4, {num:15, onUpdate:updateText, onComplete:resetTween, ease:Linear.easeNone});
}
function updateText():void
{
fifteen_TF.text= String(int(num));
}
function resetTween():void
{
//fifteen_TF.text= "";
//updateText();
}
moveNums();

Link to comment
Share on other sites

Try this:

 

 

import com.greensock.*;
import com.greensock.easing.*;

var form:TextFormat= new TextFormat("Arial", 25, 0);
var fifteen_TF:TextField= new TextField();
fifteen_TF.defaultTextFormat= form;
fifteen_TF.x= fifteen_TF.y= 200;
addChild(fifteen_TF);
var num:int= 0;
function moveNums():void
{
TweenLite.to(this, 4, {num:15, onUpdate:updateText, onComplete:moveNumsComplete, ease:Linear.easeNone});
}
function updateText():void
{
fifteen_TF.text= String(int(num));
}

function moveNumsComplete(){
//so that you can read the number 15 for  little bit, wait .5 seconds and then reset everything
TweenLite.delayedCall(.5, resetNums);
}

function resetNums():void
{
  fifteen_TF.text= "";
  num = 0;
  moveNums();
}
moveNums();

  • Like 1
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...