Home
HomeFlexible, Lightweight and Truly Skinnable Flash ComponentsPHPObject and other Flash ExtensionsForumsBlog JournalLinks
Buy Flash Components
  PHPObject - Opensource PHP Flash Remoting

redhand The PHPObject() Constructor

PHPObject(remoteclass[, gateway][, flag][, initParams])
remoteclass 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


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.


The basic constructor
Usually you would simply create the PHPObject passing the class name as the single parameter.


// Actionscript
myFoo = new PHPObject("Foo");


Using a different 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");


Switching off retrieval of properties from server
Sometimes, you may not want the server to return the properties of the remote object to Flash. This is especially true if you know you are not going to need the data. You might be using the remote object to perform some server side tasks that will never affect the object's properties. Or the server task may use the object properties without ever changing them (it returns a result instead, for example). You may be using remote methods that take in parameters and return results without looking at the object's properties (or updating them).

If you just want to invoke a remote method, perform a server-side task, and receive a result, you can switch off the retrieval of the remote object's properties. This can save you quite a bit of bandwidth by trimming the return message. You set this behavior by passing a third parameter when creating the PHPObject:

// Actionscript
myFoo = new PHPObject("Foo","http://mydomain.com/Gateway.php",1);
myFoo = new PHPObject("Foo","",1);


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]);


>> Documentation <<

 
Contact UsSite Map
Copyright © 2003-2006 GhostWire Studios