You're absolutley correct- always make anything that you need to manipulate a movieclip- that way you have control over it.
OK, what this script does is to take a dynamically loaded word and make it animated by splitting the word into an array and then feeding each element of this array into a movieclip of its own. So we start off with a text file like so-
Code:
//should say hello here but sitepoints editor is truncating it
myWord=h:e:l:l:o
Note the ':' between each letter- this is imperative to allow the array.split() method which will be used later on to feeed the text into an array. For now, save that as mytext.txt. Now transfer your attention to MX and look at this code-
Code:
//hides the seed clip
_root.text_mc._visible=false;
//loads in and deals with the loaded text
loadVarsText = new loadVars();
loadVarsText.load("mytext.txt");
loadVarsText.onLoad = function(success) {
if (success) {
//do something
} else {
//do something else
}
}
What this code does is to create a new loadvars object, tell it what to load and create a function that decides what to do next depending on wether the text was successfully loaded in or not.
Now, note the very top line of code. What this does is to hide the 'template' movieclip- this movieclip is what will get duplicated with each duplication storing one letter from the text.
Okay, now its time to replace the 'do something' bits with real code-
Code:
//hides the seed clip
_root.text_mc._visible=false;
//loads in and deals with the loaded text
loadVarsText = new loadVars();
loadVarsText.load("mytext.txt");
loadVarsText.onLoad = function(success) {
if (success) {
//creates a new array
textHolder= new Array();
//splits the variable 'myWord' defined in your text file
textHolder = _root.myWord.split(":");
//sets x to have a value of the same number of items in the new array
x=textHolder.length;
//a for loop that duplicates the movieclip called 'text_mc'
//and pushes each letter into the dynamic text box in each
//duplicated clip
for (i=0; i<=x; i++) {
_root.text_mc.duplicateMovieClip ("letter_"+i, i);
_root["letter_"+i].input = textHolder[i-1];
//spaces them out evenly, one on top of the other
if (i != 1) {
_root["letter_"+i]._y = _root["letter_"+(i-1)]._y+_root["letter_"+(i-1)]._height+10;
}
}
} else {
//do something else
}
}
Thats it really. Obviously the effect is not the same- you can easily add alpha tweens or whatever effect you need.
Post back if its still not happening for you
Bookmarks