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.
Very useful indeed, as you mentioned no where had actually put all this info in 1 place.
On a side note, not to be annoying, but the colours on the site really hurt my eyes (hard to read), I had to copy and paste this info into word….
Thanks again!
Ross
Thanks Ross.
Yeah, I think I need to add a code highlighting plugin to my WordPress.
Thanks for the feedback and glad this was of use to you.
The link to the post on the Codeigniter forum is not working:
“The following errors were encountered
You are not authorized to perform this action”
Hello Enrique,
You might need to register and log in with the forums. It never used to be like that.
this post:
http://codeigniter.com/forums/viewthread/54430/#269161
Error
The following errors were encountered
You are not authorized to perform this action.
where could’ve this post be redirected or what could the contents be?…
have any idea?…
i have to finish this project before my school deadline…
this link appears to be broken…
http://www.newvibes.com/2007/07/13/returning-query-results-from-codeigniter-models-using-amfphp-ci-and-flash/
You need a login for the codeigniter forums.
i already did… i have an account there..
do you happen to have a zip file?… may i ask for it as my basis to successfully connect AS2, amfphp and CI.. i’ve been trying to configure it for almost a week now and had no luck. i’m not really so good with these things.
Hi, I’ve no zip file but I can tell you the code was AS3. If the link above doesn’t exist any more then I have no idea where to find it, it seems as though the thread has been deleted from the forums.
i followed the instructions above and had successfully installed amfphp and loaded the browser… i stopped at the part with the deleted thread.. will you guide me?… i really need it badly.. :’(
Try this URL. http://www.newvibes.com/blog/query-results-from-ci-models-using-amfphp-ci-and-flash/
nice! thanks a million!!!