Got a request?
Email us...

ActionScript Reference crumb.gif PHPObject Class crumb.gif PHPObject()

PHPObject()

Note
This requires the PHPObject extension, available from Macromedia Exchange.

Description
Constructor. The PHPObject() constructor is used to create an object in Flash and link the object to a remote PHP class on the server.

When a PHPObject is created in Flash, the object will automatically connect to the server, retrieve the default properties of the PHP class, and populate the PHPObject in Flash.

Thereafter, you can call methods of the PHP class directly from within Flash as if the methods were declared in Flash itself.

Syntax
PHPObject(remoteclass[, gateway][, flag][, initParams])
class String, specifying the PHP class you want to link the object to
gateway String, optional, specifying the path to the gateway
flag Boolean, optional, specifying the PHP class you want to link the object to
initParams Array, optional, specifying the parameters to pass to the PHP class constructor

Example: The basic constructor
Usually you would simply create the PHPObject passing the PHP class name as the single parameter:
--------------------------------------------------------------------------------
// Actionscript
myFoo = new PHPObject("Foo");

--------------------------------------------------------------------------------

Example: Overriding default gateway
If you wish to override the default gateway, or did not have a default declared in the first place, you can pass a second parameter when creating the PHPObject. This allows you to use different gateways (perhaps with different services available) in a single application.
--------------------------------------------------------------------------------
// Actionscript
myFoo = new PHPObject("Foo","http://mydomain.com/private/Gateway.php");

--------------------------------------------------------------------------------

Example: Switching off remote data retrieval
Sometimes, you may only be calling a remote method, without wanting any data back from PHP. In this case, you can reduce the return message size (faster response) by switching off the remote data retrieval:
--------------------------------------------------------------------------------
// Actionscript
myFoo = new PHPObject("Foo","",1);

--------------------------------------------------------------------------------

Example: Passing parameters to remote object's constructor
Sometimes, your remote class may have been written such that it takes in one or more parameters when declaring a new object. Example:
--------------------------------------------------------------------------------
// PHP
class Foo
{
function Foo($firstname,$lastname)
{
$this->fullname = $firstname." ".$lastname;
}
}

--------------------------------------------------------------------------------

As of v1.43, you can pass the parameters for the remote object's constructor using the fourth parameter when declaring a new PHPObject in Flash. Remember to pass the parameters as an array:
--------------------------------------------------------------------------------
// Actionscript
myFoo = new PHPObject("Foo","","",[firstname,lastname]);

--------------------------------------------------------------------------------

REFERENCE SEARCH


RELATED ENTRIES

...bject.utf8encode()
...Object.getOutput()
PHPObject.execute()
...ect.delayExecute()
...ect.abortExecute()

LINK TO US