2 Replies Latest reply: Apr 20, 2012 10:29 AM by veontomo RSS

    convert a string into a movie clip in as3.0

    veontomo

      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.

        • 1. Re: convert a string into a movie clip in as3.0
          PenderP

          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.

          • 2. Re: convert a string into a movie clip in as3.0
            veontomo Community Member

            Great! I use com.greensock package and the first option was exactly what i needed. Thanks a lot!