Welcome, Guest
  • Author Topic: calling text in with AMFPHP  (Read 1971 times)

    welly

    • Jr. Programmer
    • **
    • Posts: 59
      • View Profile
      • Email
    calling text in with AMFPHP
    « on: 07/22/04, 09:00 »
    I am using the following code

    news_txt.html = true;
    #include "NetServices.as"
    #include "NetDebug.as"

    NetServices.setDefaultGatewayUrl("gateway.php")
    var gatewayConnection = NetServices.createGatewayConnection()
    service = gatewayConnection.getService("albums", this)

    getNews_Result = function(rs){
    cant = rs.getLength() //how many rows are in our recordset?
    for(var i=0; i<cant; i++){
    //Dynamic put base on stage and fetch data to it
    this.news_txt.htmlText = rs.getItemAt(i).Comments
    }
    }
    service.getNews()


    to call in text from mysql  
    with the service albums, this service is calling in other text and datagrid options

    <?php

    class albums{
       //change to match your needs
       var $dbhost = "localhost";
       var $dbname = "league";
       var $dbuser = "*****";
       var $dbpass = "*****";

         function albums(){
           $this->methodTable = array(
               "getItems" => array(
                 "description" => "Returns step4 table",
                 "access" => "remote" // available values are private, public, remote
                 //"arguments" => array ("message")
               ),
               "setItems" => 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")
               ),
               "getDad" => array(
               "description" => "returns dad table",
               "access" => "remote"
               ),
             "getAdam" => array (
             "description" => "returns adam table",
             "access" => "remote"
             ),
             "getNews" => array (
             "description" => "returns news table",
             "access" => "remote"
             ),
             "getDate" => array (
             "description" => "returns date table",
             "access" => "remote"
             )
           );

             // Initialize db connection
             $this->conn = mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpass);
             mysql_select_db ($this->dbname);

         }
         function getItems(){
           return mysql_query("SELECT  * FROM  `step4` ORDER  BY  `position`  ASC  LIMIT 0 , 30 ");
             }
         function getDad(){
            return mysql_query ("select Comments from dad");
             }
        function getAdam (){
              return mysql_query ("select Comments from adam");
             }
        function getNews (){
              return mysql_query ("select Comments from news");     
             }
       function getDate (){
             return mysql_query ("select Comments from date");
             }
         function setItems($rs){
          $error = false;
          for($i=0; $i<sizeof($rs); $i++){
             $result = mysql_query("replace into step4 values('".$rs[$i]['ID']."', '".$rs[$i]['team']."', '".$rs[$i]['position']."', '".$rs[$i]['played']."', '".$rs[$i]['won']."', '".$rs[$i]['drawn']."', '".$rs[$i]['lost']."', '".$rs[$i]['goaldiff']."', '".$rs[$i]['points']."','".$rs[$i]['GF']."','".$rs[$i]['GA']."')");
             if(!result) $error = true;
             }
             
          if(!$error) return "Ok"; else return "Error";
         }
    }
    ?>

    Net connection debugger says all ok !
    but sometimes I will not get any of the text and sometimes I will, any ideas ?

    authored on mac os 10.3 using AS1 components as AS2 will not install


    welly

    • Jr. Programmer
    • **
    • Posts: 59
      • View Profile
      • Email
    Re:calling text in with AMFPHP
    « Reply #1 on: 07/23/04, 06:06 »
    Also on some browsers I get this script is causing flash player to run slow ?
    I dont know if this is linked

    can anyone see any infinite loops ?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:calling text in with AMFPHP
    « Reply #2 on: 07/23/04, 09:17 »
    Seems to be ok, When infinite loops are, you need to check for ... in loops, so based on your script, the only one is:

    for(var i=0; i<cant; i++){ ...

    trace cant to be sure that always have some value.

    Follow the NetConnection Debugger ... are you receiving something but it's not showed in Flash? Or you're not receiving anithing?

    Jorge

    welly

    • Jr. Programmer
    • **
    • Posts: 59
      • View Profile
      • Email
    Re:calling text in with AMFPHP
    « Reply #3 on: 07/23/04, 10:35 »
    Netconnection debugger recieves all data (all ok , i can read it all there)
    but it does not appear in the dynamic text boxes ?
    would that be a loop ?

    how can i trace cant ?
    i do trace (cant);  and get undefined ?

    I am using cant in all 3 of my text boxes does that matter
    « Last Edit: 07/23/04, 10:44 by welly »

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:calling text in with AMFPHP
    « Reply #4 on: 07/23/04, 10:49 »
    If you get undefined your for loop doesn't work. Try using:

    cant = rs.length

    Jorge

    welly

    • Jr. Programmer
    • **
    • Posts: 59
      • View Profile
      • Email
    Re:calling text in with AMFPHP
    « Reply #5 on: 07/23/04, 11:01 »
    I Get the same ?

    have I got this right this check rows in recordset ?

    getDate_Result = function(rs){
    cant = rs.length() //how many rows are in our recordset?
    for(var i=0; i<cant; i++){
    //Dynamic put base on stage and fetch data to it
    this.date_txt.htmlText = rs.getItemAt(i).Comments
    }
    }
    service.getDate();

    well I only have one so do I need this ?

    can i do this instead ?

    getDate_Result = function(rs){
    this.date_txt.htmlText = rs.getItemAt(i).Comments
    }
     
    service.getDate();
    « Last Edit: 07/23/04, 11:13 by welly »

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:calling text in with AMFPHP
    « Reply #6 on: 07/23/04, 11:09 »
    length is a property not a method, so get ride of parenthesis, should be

    cant = rs.length //whitout parenthesis

    If you get undefined,check in the NetConnection Debugger that you're receiving some rows.

    Jorge

    welly

    • Jr. Programmer
    • **
    • Posts: 59
      • View Profile
      • Email
    Re:calling text in with AMFPHP
    « Reply #7 on: 07/23/04, 11:14 »
    I modified post above
    I only have 1 row ?

    do i need the cant thing ?


    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:calling text in with AMFPHP
    « Reply #8 on: 07/23/04, 11:20 »
    You can do

    date_txt.htmlText = rs.getItemAt(0).Comments //don't use the word "this"

    Jorge
    « Last Edit: 07/23/04, 11:20 by Jorge Solis »

    welly

    • Jr. Programmer
    • **
    • Posts: 59
      • View Profile
      • Email
    Re:calling text in with AMFPHP
    « Reply #9 on: 07/23/04, 12:01 »
    Jorge !

    you star !!

    I changed all the code for the 3 texts to

    getDate_Result = function(rs){
    date_txt.htmlText = rs.getItemAt(0).Comments
    }

    or getDad etc.

    and now it loads quicker and all the text seems to appear everytime now !!
    thank you very much this message board is the best

    if you wish to see the site http://www.afcdons.net