CodeIgniter, AMFPHP and Flash
Well I’ve finally managed to get CodeIgniter models working with my Flash movies using AMFPHP and some help from a few people on the web. I’ve managed to gather all the information together to come up with a pretty straight forward set of instructions in order to do this.
People have done things similar to what I was wanting but the information was scattered all over the web so I wanted to bring it all together in case anyone else finds this useful.
Essentially what I wanted to do was build a CMS system using CodeIgniter. The HTML views were basically for testing only as I wanted to put a Flash based interface on top which would then communicate with the CodeIgniter models and functions.
The first step is to follow the guide on the CodeIgniter wiki. You only need to create the first three files, but follow the guide carefully.
I put these three files in a folder called Abstraction, in my root. This also contains my AMFPHP install. The Abstraction folder is in the same folder (root) where the System folder for CodeIgniter resides. Of course you can call your Abstraction folder anything you want.
The next thing to do is follow the instructions at the following post on the CodeIgniter forums.
Once you have done thing make sure all your paths are correct. A good way to test is to use the AMFPHP service browser which comes with your AMFPHP installation.
The next thing you need to do is insert the Actionscript code into your flash movie.
The following is the code I used for my flash movie. I placed this on my first frame but I guess you can place it wherever you need it to go if you are putting your AS code on the time-line.
// USE AMFPHP
import mx.remoting.*;
import mx.rpc.*;var gatewayUrl:String = “abstraction/gateway.php”
NetDebug.initialize();
var _service:Service = new Service(gatewayUrl, null, ‘YourServiceName’, null , null);
var UK:PendingCall = _service.sayHello();
UK.responder = new RelayResponder(this, “handleResult”, “handleError”);function handleResult(re:ResultEvent)
{
trace(’String: ‘ + re.result);
}function handleError(fe:FaultEvent)
{
trace(’There has been an error’);
}
// END AMFPHP
The service should be calling your function from your CodeIgniter forum, and depending on what your particular function does it will return data back to your flash movie.
I’ve taken this a step further…
Well I’ve finally managed to get CodeIgniter models working with my Flash movies using AMFPHP and some help from a few people on the web. I’ve managed to gather all the information together to come up with a pretty straight forward set of instructions in order to do this.
People have done things similar to what [...]


July 13th, 2007 at 12:59 pm
I’ve also been having some issues returning Objects such as arrays, but a post by Jen deHann introduced me to the ObjectDumper in Flash.
I’m going to write a seperate post on returning database queries from CodeIgniter models into your Flash movie using AMFPHP.
August 17th, 2007 at 9:53 am
I was trying to use amfphp with code igniter. I followed the wiki - instructions for calling model from outside.
It seems to be working; can call model function from the service.
But, how can we use the libraries used in the applications folder?
Is there any implementation such that the flash service request are passed to a controller within CI and we can use the libraries and models effectively?
With the above implementation those user libraries in the applications folder that make use of the models are not working when I manually ‘require once’ them..
Can you please help in using the application libraries in service.php just like we use in controllers..
Many thanks in advance..