• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Flash Remoting and PHP > 9.5. Using AMFPHP with PHP Classes

Using AMFPHP with PHP Classes

If you want to connect Flash to PHP code via AMFPHP, you need to write your PHP code as a PHP class. The remote methods that your ActionScript code calls are the methods of your custom classes. A PHP class uses the following syntax:

class MyClass {
  var local1 = 1;
  var local2 = 2;

  function MyClass ( ) {
    // do something
  }

  function someMethod ($val) {
    // do something else
  }

  function someOtherMethod ($val0, $val1) {
    // and something else
  }
}

In this case, local1 and local2 are instance variables (unique variables associated with each instance of this class). The function MyClass( ) is this class’s constructor, which runs when an instance of this class is first created. This method performs necessary setup for an instance of this class. Finally, someMethod( ) and someOtherMethod( ) are two sample methods to which all instances of this class have access.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint