Using Dynamic Text in Flash

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Using Dynamic Text in Flash
redhot_2oo3
PayPal Donation
CZ Moderator
redhot_2oo3 has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Codezwiz Elf
Website:
Status: Offline
Joined: Aug 26, 2003
0.08 posts per day
Posts: 633
Points: 25,047
   
Here is an easy but very useful tutorial on Dynamic Text.

I used Flash MX for this, but MX2004 should be pretty much the same.

Open a new document and import of make any background you may need. I made a simple notepad image. Place your image on the stage at frame one in layer one. Note that the whole movie will only take one frame in this example.

Create a Dynamic Text Box and place it where you want the text to appear. Pick the font, colour and font size, and give it an instance name of dtbox

Make a new layer and add the following open the Actions section. Add this Actionscript:

var contentVars = new LoadVars();
contentvars.onLoad = function(ok) {
if (ok) {
dtbox.text = contentVars.content ;
}
};
contentvars.load('ramblings.txt')

You can see that we're giving the our intended text a variable name of content. We're then telling it to put the content into our dynamic text box. Finally we're telling it where to find the content.

Now open Notepad and make a text file beginning with content=
Add your text and then save the file as ramblings.txt and save the flash file in the same folder.
If you test the movie now, you should see it working. Remember when you export the swf that the text file must be in the same folder.

Here's my working example.
[ Register or login to view links on this board.]




_________________
Back to top Reply with quote
#2   re: Using Dynamic Text in Flash
bpat1434
CZ Newbie
bpat1434 has been a member for over 19 year's 19 Year Member
usa.gif maryland.gif
Occupation: EMT, Community Assistant, Webmaster, Firefighter, Web Host
Age: 40
Gender: Male
Website:
Status: Offline
Joined: Jan 19, 2005
0.00 posts per day
Posts: 21
Points: 783
AIM Address Yahoo Messenger MSN Messenger 
You may wish to add an error catch in there.

if(ok){
/* Do it */
}
else{
dtbox.text = "Error opening the file. Please report this to an Admin. Thank you.";
}

Just a suggestion.

~Brett



Back to top Reply with quote
#3   re: Using Dynamic Text in Flash
whitebox
CZ Super Newbie
whitebox has been a member for over 19 year's 19 Year Member
usa.gif ohio.gif
Gender: Male
Website:
Status: Offline
Joined: Nov 01, 2004
0.01 posts per day
Posts: 45
Points: 1,172
 Yahoo Messenger MSN Messenger 
how do i use this to create flash navbar that will load link name and link url from external txt file ?



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum