Solved

Dynamic TextField Animation

Posted on 2008-09-30
3
912 Views
Last Modified: 2013-11-11
Hello,
I'm trying to create a dynamic text animation as shown below.
But I'm not able to make it work.
I also tried create a MovieClip instance and added to timeline and added the TextField to over the MovieClip instance (like myMovie.addChild(myText))
However, result wa same. How do I make this work?
Please someone advise.
Thank you.

package

{

 

    import flash.display.MovieClip;

    import flash.text.TextField;

    import flash.text.TextFormat;

    import flash.text.AntiAliasType;

    import fl.transitions.Tween;

    import fl.transitions.easing.*;

 

    public class textAnimation extends MovieClip

    {

 

        

        [Embed(source='/assets/verdana.ttf', fontName="Verdana" mimeType="application/x-font-truetype")]

        

        private var myMovie:MovieClip;

        private var myTween:Tween;

        

        private var myText:TextField;

        private var myTextFormat:TextFormat;

        

        public function textAnimation()

        {

            

            createText();

            setLabel("This is My Text");

            

        }

        

        private function setLabel(str:String):void

        {

            myText.text = str;

        }

        

        private function createText():void

        {

 

 

            myTextFormat = new TextFormat();

            myTextFormat.font = "Verdana";

            myTextFormat.color = 0x00000;

            myTextFormat.size = 15;

            

            myText = new TextField();

            myText.width = 200;

            myText.defaultTextFormat = myTextFormat;

 

 

            myText.embedFonts = true;

            myText.antiAliasType = AntiAliasType.ADVANCED;

            

            //myText.alpha = 0;

            myText.antiAliasType = AntiAliasType.NORMAL;

            addChild(myText);

    

            

            myTween = new Tween(myText, "alpha", None.easeNone, 0, 1, 2, true);

            

            

        }

        

    }

    

    

}

Open in new window

0
Comment
Question by:eb110k
  • 2
3 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 22611752
what is this?
 [Embed(source='/assets/verdana.ttf', fontName="Verdana" mimeType="application/x-font-truetype")]

i pasted your code into an as file, ran it, and i got a java run time error, reinstall flash !!!!arrgggghhh
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 22612123
i just checked it out in Colin Moock's book and i tried one of his examples and it doesn't work.
odd.
his examples doesn't include a mime type though.
0
 
LVL 4

Accepted Solution

by:
daleyjem earned 500 total points
ID: 23198470
Try the attached snippet. There is a way I've been able to find that you can do this without embedding the font (in the case of a System font like you're using). You basically apply a blank filter to the TextField and it allows alpha tweening. I'm  pretty sure you can use a filter of any type, but I've used a DropShadowFilter in my example.

To implement on say something like an actions layer in your FLA, you might use:

var myAnimation:textAnimation = new textAnimation("Dude");
addChild(myAnimation);
package

{

	import flash.filters.DropShadowFilter;

    import flash.display.MovieClip;

    import flash.text.TextField;

    import flash.text.TextFormat;

    import flash.text.AntiAliasType;

    import fl.transitions.Tween;

    import fl.transitions.easing.*;

 

    public class textAnimation extends MovieClip

    {   

        private var myMovie:MovieClip;

        private var myTween:Tween;

        private var blankTextFilter:DropShadowFilter;

        private var myText:TextField;

        private var myTextFormat:TextFormat;

        

        public function textAnimation(textString:String)

        {

            createText(textString);

        }

        

        public function setLabel(str:String):void

        {

            myText.text = str;

        }

        

        private function createText(textString:String):void

        {

			blankTextFilter = new DropShadowFilter(0, 0, 0, 0);

			

			myText = new TextField();

			myText.text = textString;

			myText.setTextFormat(new TextFormat("Verdana", 15, 0x000000));

			myText.filters = [blankTextFilter];

			myText.width = 200;
 

			addChild(myText);

    

			myTween = new Tween(myText, "alpha", None.easeNone, 0, 1, 2, true);   

        }   

    }   

}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Migrate From Flash Media Server 4.5 To IIS Smooth Streaming or VLC 6 1,133
YouTube Link 10 354
Action Script coding 1 173
Flash content not working in IE 11 on Windows 8.1 3 155
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now