Flex and AMFPHP

Questions regarding AIR and Flex.

Flex and AMFPHP

Postby bennyhill » Sat Aug 09, 2008 2:57 am

I am just starting in Flex and I also just watched Lee's tutorial's on AMFPHP. For Flex to call functions from a php file that interacts with a database, do I need AMFPHP for this? Or does Flex already have what it needs to exchange AMF data with a php file?
Posts: 18
Joined: Sat Aug 09, 2008 2:50 am
Flash Version: Adobe Flash CC 2014

Re: Flex and AMFPHP

Postby bebo925 » Sat Aug 09, 2008 11:39 am

There are 3 ways for flex to call remote procedures. I use remote object in conjunction with AMFPHP. it is still easy to set up and even easier to use. it takes like half the code.

you need to add an xml file called services-config.xml to your src folder and edit one line of code where it says yourdomainhere (you can copy this from project to project)
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
      <service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">
         <destination id="amfphp">
               <channel ref="my-amfphp"/>
      <channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
         <endpoint uri="http://www.yourdomainhere.com/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>

you need to add a command under Project Properties->Flex Compliler->Addition Compile Arguements:-services "services-config.xml"
the entire line looks like: -locale en_US -services "services-config.xml"

do the usual AMFPHP setup

Code: Select all
 <mx:RemoteObject id="instanceName"  source="phpClassName" destination="amfphp">
        <mx:method name="methodName"  result="makeAFunction()"/>

and you call the method with:
Code: Select all
User avatar
Posts: 544
Joined: Tue Aug 22, 2006 2:51 am
Flash Version: Adobe Flash Builder
Authoring Environment: Microsoft Windows

Return to AIR and Flex

Who is online

Users browsing this forum: No registered users and 1 guest