Dynamic Text Effects in Flash

Loading the text using text file.

1.First we create a text file with one variable.
for example
myVariable=<p class=’header’>Welcome to brianwiltshire.net</p><p>In this example i will illustrate how to load an external text file into flash and then style it with an external stylesheet. Yes that’s right CSS,  dynamic text and Flash</p>
<p class=’footer’><a href=’http://www.brianwiltshire.net’>Click here for more info.</a></p>

2.After that we create the css file for the class which we apply in the text file

p{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color:#999999;
}

.header{
font-size: 18px;
font-weight:bold;
color:#FF9933;
}

.footer{
font-family:Geneva, Arial, Helvetica, sans-serif;
text-align:right;
}

a{
color:#FF0000;
text-decoration:underline;
font-weight:bold;
font-size: 10px;
}

3.Create the dynamic text field in flash.give the instance name as myText_txt
4.Convert this text field into movieclip & give the instance name as text_mc.
5.Double click the movieclip,create the new layer named as actions:
paste this code for loading the css file into flash,one function called for loading the data from that text file
(name.txt) file.

var myStyle = new TextField.StyleSheet();
myStyle.load(“myStyle.css”);
myStyle.onLoad = function() {
myText_txt.styleSheet = myStyle;
};

textLoader();

function textLoader() {
myData = new LoadVars();
myData.onLoad = function() {
myText_txt.html = true;
myText_txt.htmlText = this.myVariable;
};
myData.load(“name.txt”);
}

6.Go to the mail clip & create the new layer and names it actions,paste the following code into that layer
this code for transaction effect with scripts,
First 2 lines are include the tween,easing transition effects from library.

import mx.transitions.Tween;
import mx.transitions.easing.*;

new Tween(text_mc, “_x”, Elastic.easeOut, Stage.width, 200, 3, true);

7. try this effect also for example only in same main actions layers to paste this code

var ball_tween:Tween = new Tween(text_mc, “_x”, Regular.easeIn, 0, 250, 3, true);
ball_tween.onMotionFinished = function() {
ball_tween.continueTo(200, 3);
};

8. Test the movie

Advertisements

Posted on November 19, 2009, in Flash and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: