• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Working example: How to populate "my_textfield" on the stage with some json data?

Community Beginner ,
Oct 28, 2017 Oct 28, 2017

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.

Views

291

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 28, 2017 Oct 28, 2017

use something like:

var this_var=this;

function parseResponseF(s){

this_var.my_textfield.text=s.name;

}

Votes

Translate

Translate
Community Expert ,
Oct 28, 2017 Oct 28, 2017

Copy link to clipboard

Copied

as3 or html5/js?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 28, 2017 Oct 28, 2017

Copy link to clipboard

Copied

Sorry...

with js in the actions panel.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2017 Oct 28, 2017

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 28, 2017 Oct 28, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2017 Oct 28, 2017

Copy link to clipboard

Copied

use something like:

var this_var=this;

function parseResponseF(s){

this_var.my_textfield.text=s.name;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 28, 2017 Oct 28, 2017

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2017 Oct 28, 2017

Copy link to clipboard

Copied

LATEST

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.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines