Jump to content
xisto Community
Sign in to follow this  
sanbeand

Getting Started With Amfphp And Rias first steps in creating RIAs

Recommended Posts

AMFPHP in a short way is a library of php files that let u manage in

JUST ONE FILE what u would do in many files like for example queries

to mysql. So u can have tons of queries to mysql and all of them in

just ONE FILE!

 

so what is a RIA? a RIA is a Rich Internet Application commonly given

to flash applications, not the animations or presentations we see

daily on the internet but very useful and cool programs made in flash.

 

the fisrt step u need to take is to download the AMFPHP library

directly from its site at http://www.amfphp.org/, in some free hosted sites

the latest versions doesnt run but the .9 version does...happily at

Xisto.net i could run the latest version 1 milestone 3 and some of

the main changes (since the milestone 1) include the utf8_decode so u

can store frech, spanish, german names, streets etc.

 

ok now while u are downloading AMFPHP lets go to the flash side, u can

download the latest version at macromedia.com (latest is 8) and as we

want to trace every action we perform we should (for sure) download the

remoting components (http://forums.xisto.com/no_longer_exists/) it helps to build easily our RIA..ok i'll wait

while u download it... :D ... :D ... well i think u

alredy downloaded it... so lets go to the construction of our first

mini RIA: :P

 

Installation NOTE: first install Flash 8 and then the remoting components

 

the first time u open flash u'll see the welcome window and a bunch of

typefiles u can choose from... and as we want to just start, choose

the flash file (fla), after u load ur new document by default Flash

has some opened panels but maybe the components panel is not! so if it

is not opened in the right panel go to Window>Component Panel and u'll

see that that new panel opens and some "compenent directories are

shown", look very closely to the User Interface and Data Components

that are the ones we are gonna use... oh! we finished downloading

AMFPHP good!... we are not gonna change anything from any file just

uncompress the folder and give a name like "flashservices" (just for

fun :P ) and then opload the "flashservices" folder to ur

hosting server, site or just move the folder if u are running a

webserver in ur computer to the root folder of the folder that ur

server use to use the files eg. for IIS the folder is

C:\Inetpub\wwwroot and for apache in my computer is C:\Program

Files\Apache Group\htdocs...

 

now it fits just like this:

>LOCALHOST/flashservices/<

 

lets leave AMFPHP and continue with flash...now that we have seen the Groups's Components drag a Combobox, a DataGrid, a TextArea and Three buttons give each component an instance name for the combobox>cb, for the Datagrid> dg fo the textArea> ta_txt and for the buttons> btn1, btn2, btn3 and put each button below each component i mean below the combobox the btn1 and so on...

ok now that u have the compoents positioned in the stage go again to the Components Panel and drag 3 Dataset from the Data group and 3 RemotinConnector from the Data Components Group(in flash 8, in previous versions both are under Data Componets) and give an instance name for each component such as ds_1 and r_con1 and so on....

ok now lets bind each component to be able to drive the data to the correct place...

select the r_con1 and in the component inspector(if it is not opend go to Window>Component Inspector) select BINDINGS and click on the big + and select Results:Object and then click ok...u'll see an item is added below, click the item and in its properties select "bound to:" and select the ds_1... do the same thing with the rest of the components...

now u finished binding the components click on the FIRST frame and go to ACTIONS (if it is not opend press F9) and paste this code:

 

btn1.onPress=function(){r_con1.trigger();}btn2.onPress=function(){r_con2.trigger();}btn3.onPress=function(){r_con3.trigger();}
ooops! i almost forget select the remoting connectors and modify its gateway to ur current location (where u put the flash services folder) e.g. LOCALHOST/flashservices/gateway.php and for the service write myTest and for the method of each component write myCb for the remotingconnector of the combobox, myDg for the datagrid's and myText for the TextArea's...

 

ok now we finished the flash side :D:P ..now lets finish the last part...

 

in amfphp files are stored as classes it means the name of the file is gonna be called as the class conatained in it... also is good to mention that u must declare each function that is gonna be used in order to be recognized by php...

copy this file under flashservices>services folder and save the file as myTest.php

 

 

<?phpclass myTest{        //change to match your needs        var $dbhost = "localhost";        var $dbname = "ur database name";        var $dbuser = "ur user";         var $dbpass = "ur password";      function myTest(){        $this->methodTable = array(         "myDg" => array(              "description" => "Returns products table",              "access" => "remote" // available values are private, public, remote               //"arguments" => array ("message")            ),            "myCb" => array(              "description" => "Returns products table",               "access" => "remote" // available values are private, public, remote              //"arguments" => array ("message")            ),            "myText" => array(               "description" => "Echoes the passed argument back to Flash (no need to set the return type)",              "access" => "remote", // available values are private, public, remote               "arguments" => array ("rs")            )        );                        // Initialize db connection                        $this->conn = mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpass);                        mysql_select_db ($this->dbname); }      function myDg(){        return mysql_query("select * from mydg");      }      function myCb(){        return mysql_query("select * from mycombo");      }        function myText(){          return mysql_query("select myText from mytext")}?>
ok we are almost done... now set up three tables with phpMyAdmin called "mydg, mycombo and mytext" for the mydg table set up these fields ID, Name; for the mycombo set up JUST myNames and for text use ID and myText...

in the mydg table write new records as follows:

ID Name

1 Andr�s

2 G�ero

 

fo mycombo table set:

 

myNames

Andr�s

G�ero

 

and finally for myText:

Andr�s is a G�ero friend

 

 

after u save all this info u can return to flash publish ur work and pressed ur buttons to see the results! and using the utf8_decode....

 

now we are done! :( u can start building powerful applications and RIAs!! hope it helps....

cheers!

 

Notice from BuffaloHELP:
Too busy posting forgot to add CODE tags? Tisk tisk...
Edited by OpaQue (see edit history)

Share this post


Link to post
Share on other sites

Problems in IIS 7

Getting Started With Amfphp And Rias

 

Hallo my frined,

Firstly let me thank you for this helpfull example.

I followed all the steps of the example one after the other but unfortunatelly it doesn't working.

I also found that when I am typing in url: //localhost/flashservices/browser/ then it comes up a page that needs a simple registration (which unfortunately doesn't works).

I have Windows Vista Premium with IIS 7.

Could you please post an example for Vista and IIS 7, or give some details who to solve this problem ?

Thank you

 

-reply by kostas

Share this post


Link to post
Share on other sites

hey bro my friend was looking for this i gave him the link and he like everything you said and he want me to say thank you so thank you very muchand hope this will help other people like it helped my friend

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.