Animate cc asynchronous issue
Hey guis,
I would like to ask is it normal behavior user to act twice when XMLHttpRequest is made throug HTML5 Canvas type in Animate CC.
Here is a very simple scenario:
On the HTML5 Canvas type document there are text field and button.A content from an external text file should loaded in a text field when a button is clicked.
After the first click of the button (by name "getContent_btn") the content is not loaded into text field(at least not displyed). User have to click one more time on the button content to be loaded (displayed) in text fied (by name "content"). There is something hidden in the load process that i miss. Although alert function shows loaded content imediately afrer first button click. Where is the problem?
Here is the loading function:
function loadXMLDoc(filename) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
currentContent = this.responseText;
alert("currentContent:"+currentContent);
}
};
xhttp.open("GET", filename, true);
xhttp.send();
}
and here is a button function and listener:
this.getContent_btn.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler()
{
loadContent("document.txt");
this.content.text = currentContent;
}
