Getting PHP Variable into Animate HTML5

Community Beginner ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

Hello, I am trying to figure out how to get the value of a PHP variable into an Animate HTML5 app to run an if/else statement. I have a PHP document that holds the Canvas and Javascripts to run the application. In the PHP file I define a variable before loading any of the Javascript or Canvas files:

<? $watch = "Yes" ?> //Which is really a result from a DB query.

In my ActionsScript within Animate I have the following code. This code is supposed to show a button if the PHP variable is equal to Yes, else hide it if not.

var watch = <?php echo json_encode($watch); ?>;
if (watch=="Yes"){
     this.next_btn.addEventListener("click", fl_MouseClickHandler.bind(this));
     function fl_MouseClickHandler(){
          this.parent.parent.gotoAndPlay(2);
     }
}else{
     this.next_btn.visible = !this.next_btn.visible;
}

When I run it on my webserver it hangs.  So I am not sure if I have the right code here for getting the PHP variable.  Any help would greatly be appreciated.

TOPICS
ActionScript , Code , How to

Views

32

Likes

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
Adobe Community Professional ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

LATEST

var xmlhttp;

var domParser = new DOMParser();


if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var xml_string = xmlhttp.responseText;
}
}

xmlhttp.open("GET", "date.php", true);

Likes

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