PHP Intergration im FLASH

hi ther!
here comes a telephone directoy of a country… with 20 cities..and each city’s data is stored in the tables of MS ACCESS.
im supposed make its interface in flash ..smthing like ==>

FRONT INTERFACE:
its a main screen with a “next” button behind the next button there are sm codes regarding actionscripting…like ==>
on (release){
signal=1;
loadVariablesNum(tel.php,0,“POST”);}
now comes to tel.php

<?php $conn = odbc_connect("Directory","",""); if($signal==1) { $query = "SELECT * FROM Cities;"; $exe = odbc($conn,$query); $result = odbc_fetch_array($exe); for($i=0;i { echo " "city_name=" odbc_result($result,$i,"city"); ";//city is the column name in database. echo " " city_code=" odbc_result($result,$i,"code"); "; } echo "signal = 2;" } else {//discus later!} ? . can i use the signal variable from action script in php as it is (just placing the $ sign b4 it!) or should i use smthing like $signal=$_POST'signal']; $signal=2; echo"signal= $signal; "; SECOND INTERFACE ther comes a searching bar while retriving the data form database and then comes to city select scene in which all the values echoed by program hav been saved in DROPDOWN MENU!! can i use same variableie city_name repeatedly in dropdown list to place the values geting 4om php ther... also evry option in the dorpdown list in actionscripting needs coding..so as the data, in this case, is retriveing from database there is a go button which takes all the variables intact ie, the selection by user, to the next scene...! THIRD SCENE all the variables ie. signal (whose value is now 2 and i think it becomes _root.signal ) and city_selected (the seleclion of the city _root.city_selected), are sent by go button to this scene after sum delay!(a loading bar or stuff!!).. this scene also hav one dropdown menu asking for search by : NAME PHONE OR ADDRESS>? then again a go button which takes 3 variables to the next secne which is search query! FOURTH scene save all the variables in ther respective names again (to putback the _root. prefix!)ie. signal=_root.signal; city_select=_root.city_select; search_by=_root.search_by; 4th scene is taking the query string 4om the user and ie. ENTER THE search_by : (<==can the variable use like dis??) save the query string in search_query string and post the variables to php loadValiablesNum(tel.php,0,"POST"); now remaining of php code : else{ $query = "SELECT * FROM $city_name WHERE $city_by LIKE '%$search_query%';";//can iuse var directly!just by placin $b4 $exe = odbc($conn,$query); echo "rows=odbc_num_rows($result)"; for($i=0;i {//swap func:recording the sizeof largst result. if($i=0) { $size_N = count($result[NAME];//name $size_P = count($result[PHONE];//phone $size_A = count($result[ADDRESS];//address } if($i { $size_N = count($result[NAME]; } if($i { $size_P = count($result[PHONE]; } if($i { $size_A = count($result[ADDRESS]; } } echo"size_N = $size_N; size_A = $size_A; size_P = $size_P;"; for($i=0;i { echo "Name = count($result,$i,NAME)"; echo "Phone = count($result,$i,PHONE)"; echo "Address = count($result,$i,ADDRESS)"; } } LAST SCENE the last secne is for printing all the records.. there is a table of constant width but variable length... the length cn be upto of 5 rows if exceded than 5 the scroll bar on. the function of the variables recived from php query are as follow: . rows = it will assign the no of rows in the table also for header of the table ie.(RECORDS FOUND = 'rows') .size_N size_P size_A= they will asign the size of the column...if they are exceed the width of table the horizontal scrolll bad opens. can i do this ..asign the size of columns no of rows by a variable! Thats all! i no i no the basic question was deviated from path but still if ne one can guide me for 1st 2-3 steps and temme of ther ne error in php code and variable handling from action script!! or reffer me to ne other fourm or site where can i find this kinnda case regarding php and actionscripting ..most wel come~~~

Re: PHP Intergration im FLASH

is it necessary for you to use loadVars or do you need to make a flash directory application in flash. I am asking this since there are many ways to skin the cat, and more sophisticated ones. Let me know, and i will explain it to you..

as far as your variable is concerned, of course you are using the 'POST' method to send it to the server side. So, it will be available as $_POST'my_var'] . Also, make sure that you append the variables with loadVariablesNum when you are making a server-side call, you should read the following (taken from flash mx 2004 help menu)


correct syntax.

Usage


loadVariablesNum (url:String ,level:Number , variables:String]) : Void


Parameters

url An absolute or relative URL where the variables are located. If the SWF file issuing this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section.

level An integer specifying the level in Flash Player to receive the variables.

variables An optional parameter specifying an HTTP method for sending variables. The parameter must be the string GET or POST. If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Returns

Nothing.

Description

Function; reads data from an external file, such as a text file or text generated by a ColdFusion, CGI script, ASP, PHP, or Perl script, and sets the values for variables in a Flash Player level. You can also use this function to update variables in the active SWF file with new values.

The text at the specified URL must be in the standard MIME format application/x-www-form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables:


company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103


In SWF files running in a version of the player earlier than Flash Player 7, url must be in the same superdomain as the SWF file that is issuing this call. A superdomain is derived by removing the leftmost component of a file’s URL. For example, a SWF file at www.someDomain.com can load data from a source at store.someDomain.com, because both files are in the same superdomain of someDomain.com.

In SWF files of any version running in Flash Player 7 or later, url must be in exactly the same domain as the SWF file that is issuing this call (see "Flash Player security features" in Using ActionScript in Flash). For example, a SWF file at www.someDomain.com can load data only from sources that are also at www.someDomain.com. If you want to load data from a different domain, you can place a cross-domain policy file on the server hosting the SWF file. For more information, see "About allowing cross-domain data loading" in Using ActionScript in Flash.

If you want to load variables into a target MovieClip, use loadVariables() instead of loadVariablesNum().

Example

The following example loads information from a text file called params.txt into the main Timeline of the SWF at level 2 in Flash Player. The variable names of the text fields must match the variable names in the params.txt file. The setInterval() function is used to check the progress of the data being loaded into the SWF. The script checks for a variable in the params.txt file named done.


loadVariablesNum("params.txt", 2);
function checkParamsLoaded() {
  if (_level2.done == undefined) {
    trace("not yet.");
  } else {
    trace("finished loading. killing interval.");
    trace("-------------");
    for (i in _level2) {
      trace(i+": "+_level2*);
    }
    trace("-------------");
    clearInterval(param_interval);
  }
}
var param_interval = setInterval(checkParamsLoaded, 100);

// Params.txt includes the following text
var1="hello"&var2="goodbye"&done="done"



Re: PHP Intergration im FLASH

okz its too messy ... now cum step by step...
can i adjust the values retrived by sql via PHP in sumthing called dynamic text box... rathar can i adjust this dynamic text feild wrt values achived by php.. viz column lenght and number of rows.... and so on... (VARIABLE SCALING OF DYNAMIC TEXT FEILD IN FLASH)

Re: PHP Intergration im FLASH

Whenever there's a situation - such as the one you are working on - where a "dataset" needs to be brought into the flash client, you have to use UI components i.e a DataGrid. There is no logic which supports adding multiple dynamic text fields corresponding to the number of rows in a result set, from a query.

there are three parts of the puzzle; the server side; the method u use to transport the data; and the client side or UI. The server side logic would be the query:

$res = mysql_query($con_id, "SELECT * FROM my_cities");

Since the recordset will likely include more than one row; either you can "echo" it in a way that it appears as an XML Object to flash OR you use can flash remoting to send that over to the client side. The latter one is more effecient, and preferable while working with database servers. The third part is to attach the recordset (once received by flash) to the DataGrid componet.

In simple terms, "query -> remoting -> datagrid" is your best bet.

Re: PHP Intergration im FLASH

thanks abdullah bhai...
actually i didnt read out ur first reply... u asked iz it compulsry to diplay the query in flash or xml... Nops its not! but i was doin xperiments with MM FLASH MX, and infact im just a beginner to MM Flash! You can cricize that i made a long jump to data base and preprocess, but indeed its my requirment.
So a question about uor last post >> u said there is no such thing exists which adjust the width of colums and number of rows of dynamic list box. Will the dynamic list box automaticcally adjust the width of colums and generate the respective rows accordingly the data retrived from PHP? is it not so, inspite of enhancing the width of columns, it sets the horizontal scroll bar "on" if the data exceeds the char limit, of the individuall cell, by default?
And finally, the fourmula that you gave bout server to client flow, i didnt really understand it!
Can u xplain the entire senario again...
Thanx a lot.

Adeel.

Re: PHP Intergration im FLASH

well, first of all, you actually CAN use XML to bring a record set in flash. But, in order to accomplish this, you would have to “echo” the entire xml structure in PHP, and then use something like XML Object class or XML Connector in flash to ‘load’ it. Also, there’s no such thing as “Text Box” in flash. There’s TextField and ListBox that can be used for data population. The DataGrid class infact inherits from the List class in flash. You can also make text fields dynamic to update them as necessary according to the data calls and updates.

Now, using XML is unnecessary to some extent I think, while working with dbs, when you have other options available such as Flash Remoting, solely designed for integration with application and database servers. Once, your queries and server side logic is properly set up, then data management, such as updates, changes, deletions etc are very easy to implement.

In fact, integration of flash with backend servers is very simple, effecient and fast. Before, I delve further into it, you should try to use the latest version of Flash (MX 2004 Professional). The entire remoting framework has been completey re-engineered in MX 2004 from the previous version. Also check out this site for PHP based flash remoting: