Copy link to clipboard
Copied
I am in front of Animate CC and in the stage I have an instance of a dymamic textfield called "my_textfield".
How to populate "my_textfield" on the stage with some data in a json file?
Do you know a working code example?
Thanks a lot.
use something like:
var this_var=this;
function parseResponseF(s){
this_var.my_textfield.text=s.name;
}
Copy link to clipboard
Copied
as3 or html5/js?
Copy link to clipboard
Copied
Sorry...
with js in the actions panel.
Copy link to clipboard
Copied
add a component to your project (or otherwise include jquery) and use:
function sendDataF(methodS,dataTypeS,urlS,dataObj,f){
$.ajax({
url : urlS,
data : dataObj,
type : methodS,
dataType : dataTypeS,
success : f,
error: function(ts) { console.log(ts.responseStatus); },
error : function(xhr, status) {
var errorS = '';
for(s in xhr){
errorS += s+' : '+xhr+'\n';
}
alert('Sorry, there was a problem!\n'+errorS+'\nstatus:'+status);
},
complete : function(xhr, status) {
var errorS = '';
for(s in xhr){
errorS += s+' : '+xhr+'\n';
}
// alert('request complete!\n'+errorS+'\nstatus: '+status);
//console.log('request complete!\n'+errorS+'\nstatus: '+status);
}
});
}
function parseResponseF(s){
//parse s
}
sendDataF("POST","json","yourjasonfilename.json",null,parseResponseF);
Copy link to clipboard
Copied
I have added a component to the proyect and I have replace the name of the json file (datos.json) containing an object in it. This is:
{
"name":"Jesper"
}
I don´t know how to parse it to populate "my_textfield" on the stage.
Copy link to clipboard
Copied
use something like:
var this_var=this;
function parseResponseF(s){
this_var.my_textfield.text=s.name;
}
Copy link to clipboard
Copied
I am using Firebug on Mozilla and now I am getting the folowing warning in the console.log : The use of Mutation Events is out of date. Use MutationObserver instead.
However, it is working. Thank you kglad!
Copy link to clipboard
Copied
you can comment out console.log if you're not using the developers edition of firefox (or use another browser that is compatible with debugging).
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)