Flash TvGuide App
Okay, heres the flash client (only 47k!) for the TVguide webservice posted recently.
It’s quite a fairly simple movie using flash remoting and amfphp. I used amf to call my tvguide webservice via SOAP. Instead of having your swf call a specifc flash service, you call a special service which acts like a proxy to SOAP webservices. This service looks like this..
1// AMFPHP uses by default the PEAR::SOAP
2// library, so you need to define in the
3// gateway not to use that. In this case
4// NuSOAP will be used
5
6// change this based on your amfphp installation
7include_once($_SERVER['DOCUMENT_ROOT'] . '/flashservices/app/Gateway.php');
8$gateway = new Gateway();
9$gateway->usePearSOAP(false);
10$gateway->service();
You connect to this via NetServices..
1this.netConn = NetServices.createGatewayConnection("http://www.nodetraveller.com/flashservices/services/WSProxy.php");
Then you specify the webservice you want by providing the endpoint to the getService method..
1this.service = this.netConn.getService("http://www.nodetraveller.com/webservices/tvGuide/tvGuideService.php?wsdl",this);
and then call the webservice method you want…
1this.service.getChannels(paramsObj);
The paramsObj is a value object holding any parameters the webservice method expects. When the data comes back you handle it the normal way..
Oh, and I had lots of fun playing about with the datagrid and creating a custom cell for it for the channel logo graphics.
Based on the Model View Architecture which works basically like this for those of you who don’t know yet: The Model is an object that handles the remoting stuff and nothing else. It just connects to remote services and handles the data when it comes in. When the data does come in, it fires of an event to the View. The View is a listener of the Model so when the Model shouts, the View jumps. Now when the user interacts with the app, its the Controller that decides what to do; call a method on the Model or the View. Nice and easy…MVC ain’t completely perfect but its very useful…
You can see the actionscript files for the Model, View or Controller or download here