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

Getting PHP Variable into Animate HTML5

Explorer ,
May 05, 2022 May 05, 2022

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
219
Translate
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 ,
May 05, 2022 May 05, 2022
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);

Translate
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