Skip navigation
veontomo
Currently Being Moderated

convert a string into a movie clip in as3.0

Apr 20, 2012 9:32 AM

Hi to everybody,

i'm quite new to action script 3.0, and before posting the question I googled, but with little success. So my question is how to convert a string into a movie clip instance?

I need it in order to handle then that movie clip instance  with tween class methods.

 

So, I've got

 

var str:String = "a";

var mc:MovieClip = new MovieClip();

 

and what I want to have as a result is that the movie clip mc contains the letter "a" inside.

 

Any suggestions are appreciated.

 
Replies
  • Currently Being Moderated
    Apr 20, 2012 10:14 AM   in reply to veontomo

    import flash.text.TextField;
    import flash.display.MovieClip;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;

    var str:String = "a";

    var myText:TextField = new TextField();

    myText.text = str;

    var myMC:MovieClip = new MovieClip();
    myMC.addChild(myText);
    addChild(myMC);
    var myTween:Tween = new Tween(myMC, "x", Strong.easeOut, 40, 300, 5, true);

     

    OR

     

    import flash.text.TextField;
    import flash.display.MovieClip;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;

    var str:String = "a";

    var myText:TextField = new TextField();

    myText.text = str;

    addChild(myText);

    var myTween:Tween = new Tween(myText, "x", Strong.easeOut, 40, 300, 5, true);

     

     

    There is quite a few ways to do this. The above may not be the most efficient or best way. Essentially, the text in your string has to be set as the text property of a text field container, and then the text field container needs to be added to the displaylist. Then it can be tweened.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points