Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

add tweening to dynamic textfield

Avatar of Mike Waller
Mike WallerFlag for United States of America asked on
Adobe Flash
5 Comments1 Solution883 ViewsLast Modified:
How can I make a dynamic textfield slide from left to right using a motion tween?  I found the following but it just blinks.  I need the text have some movement:

Here is a slightly different approach, and you might be interested in straight up dynamic textfield tween. I use this general methodology to animate text I load in (use LoadVars is easier in my opinion). What you need to do first is right click or mac click in your library and choose "New Font", which effectively embeds that into your swf file. Then right click on it and give it a linkage identifier of "Font". Make sure you have "recipe.txt" in the same directory.

Just make a new .fla and save it in the same directory, with that font in the library. When you run the code below your textfields should alpha fade in and out on the stage every 2 seconds:

import mx.transitions.Tween;
import mx.transitions.easing.Regular;
var text_mc:MovieClip = this.createEmptyMovieClip("text_mc", 0);
var lv:LoadVars = new LoadVars();
lv.onLoad = function()
{
     delete this.onLoad;
     createText();
};
lv.load("recipe.txt");
var txtArr:Array = new Array();
function createText(Void):Void
{
     var c:Number = 0;
     for (var i in lv)
     {
          text_mc.createTextField("txt"+c, c, 0, 0, 0, 0);
          var txt:TextField = text_mc["txt"+c];
          // textformat
          var tf:TextFormat = new TextFormat();
          tf.font = "Font";
          with (txt)
          {
               embedFonts = true;
               autoSize = true;
               setNewTextFormat(tf);
               text = lv[i];
          }
          txt._y = c*txt._height;
          txtArr.push(txt);
          ++c;
     }
     fade();
     setInterval(fade, 2000);
}
function fade(Void):Void
{
     for (var i = 0; i<txtArr.length; ++i)
     {
          if (txtArr[i]._alpha == 0)
          {
               var finishAlpha:Number = 100;
          }
          else
          {
               var finishAlpha:Number = 0;
          }
          txtArr[i].tween_alpha = new Tween(txtArr[i], "_alpha", Regular.easeOut, txtArr[i]._alpha, finishAlpha, 1, true);
     }
}

ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh ChopraFlag of India imageFounder | CTO
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answers