PHP: Connecting Flash to a Database (remoting)


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* /flashservices/services/Catalog.php */
  2. class Catalog {
  3. var $products_array = array();
  4.  
  5. // Constructor: Contains the list of methods available to the gateway
  6. function Catalog() {
  7. $this->methodTable = array (
  8. "getProducts" => array (
  9. "description" => "Get list of products",
  10. "access" => "remote",
  11. "arguments" => "" // arguments could be optional, not tested
  12. )
  13. ); // end methodTable
  14. }
  15.  
  16. function getProducts() {
  17. // your code goes here
  18.  
  19. return $this->products_array;
  20. }
  21. }
  22.  
  23.  
  24. #include "NetServices.as"
  25. NetServices.setDefaultGatewayUrl("http://yourserver.com/flashservices/gateway.php");
  26. gw = NetServices.createGatewayConnection();
  27. CatalogREMOTE = gw.getService("Catalog", this);
  28. CatalogREMOTE.getProducts();
  29.  
  30. getProducts_Result = function(result) {
  31. _root.products_results = result;
  32. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.