Copy link to clipboard
Copied
Hello, in flash we was able to load text in dynamic text field from external .XML file. Does anyone know how can I do that in Adobe Animate?
var r = new XMLHttpRequest();
r.addEventListener("load", rF);
r.open("GET", "path/file.xml", true);
r.send();
function rF(e) {
alert(e.target.response);
}
Copy link to clipboard
Copied
Of course, all files are named correctly, I've checked them double, triple, and hundreds more times. It's maybe only here in a chat are some mistakes, just describing the situation.
! But placing all those files on a server and reaching them through the web does the trick. The page can reach and load an external file.
I will never understand where is the golden key. And sorry for the fact I need those files locally - I can't do anything with them online.
It seems to me I'll never go through... Too many questions are on their way. And I still can not "load the external text file" to get some data for use in my project further.
Thanks for helping - it's all my fault (no - stupidity)
Copy link to clipboard
Copied
google how to circumvent cross-domain security issues, if that's what you want.
Copy link to clipboard
Copied
I've got an external text file, and i'd like to know,
I want to have each word in the file on one dynamic text field.
Can you help?
Copy link to clipboard
Copied
are the textfields on stage or are you going to create them dynamically using a movieclip with linkage id or some other way?
Copy link to clipboard
Copied
Linkage
Copy link to clipboard
Copied
create a movieclip that contains a textfield with instance name tf. give that movieclip a linkage of MC_TF
you can then use:
// assign your parameters
var colNum=10;
var wordspace=6;
var leading = 30;
// load your text file
r.open("GET", "text.txt", true);
r.addEventListener("load", rF.bind(this));
r.send();
function rF(e) {
createTF.bind(this)(e.target.response.split(" "));
}
function createTF(a){
for(i=0;i<a.length;i++){
var tf_mc = new lib.TF_MC();
tf_mc.x = (i%colNum)*wordspace;
tf_mc.y = leading*Math.round(i/colNum);
this.addChild(tf_mc);
tf_mc.tf.text = a[i];
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
and what is it about the code i suggested that does not do what you want?
Copy link to clipboard
Copied
It just show the text on one textbox and not the others.
I'll give the code a try.
Copy link to clipboard
Copied
no it's not
Copy link to clipboard
Copied
I'm using dynamic text for the text file, but I'm trying out the loop trick.
Is it possible? Thanks for the help.
Copy link to clipboard
Copied
i don't understand what you're asking now and i don't understand how you could've possibly used the code i suggested and had the problem you had. so, i suspect you're not following the suggestions i've made.
that's generally not an issue, but if what you use is different from what i suggest, and what you use fails, don't report that my suggestion fails.