A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Bringing data into flash

  1. #1

    Bringing data into flash

    I have a problem with getting data into flash through php can someone pleas help. i have a mc with a textfield inside of it and I use --onClipEvent (data) {
    this.play();}
    in the first frame of the mc is --
    fla_body = "";
    loadVariables("broadcast.php?"+(Math.random()*1000 000), this);
    stop();
    below is the phpcode (//flash part) is where it should happen

    PHP Code:
    <?php
    /* this function takes a given string and does an explode by [url] 

    */
    function createLink($url){
        
    // $tmp = a temporary array created by the explode function
        
    $tmp explode("[url]",$url);
        
    // sizeof(anygivenarray) = number of elements in the array
        
    for ($i=1$i<sizeof($tmp)-1$i+=2){
            
    // creates a link out of the given url
            
    $tmp[$i]="<a href=\"http://".$tmp[$i]."\" target=\"blank\">".$tmp[$i]."</a>";
        }
        
    // returns a string from the array $tmp
        
    return implode("",$tmp);
    }

    function 
    createmailto($email){
        
    $tmp explode("[email]",$email);
        for (
    $i=1$i<sizeof($tmp)-1$i+=2){
            
    $tmp[$i]="<a href=\"mailto:".$tmp[$i]."\">".$tmp[$i]." </a>";
        }
        return 
    implode("",$tmp);
    }

    // this includes the database connection
    include "broadcast.inc";

    // query the table news and sorts them, this is done in oder to present the last entry at the top of the table insted of the bottom
    $result mysql_query("SELECT * FROM news ORDER BY posted ASC");

    // Count the number of rows in $result, $result is the above var. that selects the table news
    $num_of_rows mysql_num_rows($result);

    //echo $num_of_rows;

    //this part makes the table for the content to be displayed in
    echo'<table width="200" border="0" class="linespacingbcast">';
    //this for loop counts $num_of_rows backwards until it is less than zero; 
    for (-- $num_of_rows$num_of_rows >= 0$num_of_rows --){
    echo

    <tr>        
     <td><span class="b-norm1">  '
    .mysql_result($result,$num_of_rows,"author").' </span> 
    <span class="bcast-date"> '
    .strftime("%a %d/%m/%y %H:%M"mysql_result($result,$num_of_rows,"posted")).'</span> <br>
    <span class="bcastnorm">  '
    createmailto(createLink(mysql_result($result,$num_of_rows,"body"))).'</span></td>
    </tr>'
    ;

    }

    echo 
    '</table>';

    //flash part
    $fla_author mysql_result($result,$num_of_rows,"author");
    $fla_posted strftime("%a %d/%m/%y %H:%M"mysql_result($result,$num_of_rows,"posted"));
    $fla_body createmailto(createLink(mysql_result($result,$num_of_rows,"body")));
    print 
    "&fla_body=" .urldecode($fla_body);

  2. #2
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Some notes:
    -loadVariables("broadcast.php?"+(Math.random()*1000 000), this);
    You don't have to make SUCH a large random number. Times 1000 would be good unless you let the client contact 20 times the php script or so.

    -include "broadcast.inc";
    Change your file to 'broadcast.inc.php'. If not and people figure out the name of your file, they can see everything in it. And that's not secure for your server.

    -Flash can only read things/variables in a specific format. '&var1=text1&var2=text2'/etc.

    But you first put some html code on the screen. Flash can't read that and that's your problem. You should have that table within an if statement or so.

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

  3. #3

    It does work

    thanks for the help

    PHP Code:
    //flash part

            
    $broadcast .= '<font color="#df12df" size="12"><b>';
            
    $broadcast .= mysql_result($result,$num_of_rows,"author");
            
    $broadcast .= '</b></font>';

           
            
    $broadcast .= '<font size="10">';
            
    $broadcast .= strftime("%a %d/%m/%y %H:%M"mysql_result($result,$num_of_rows,"posted"));
            
    $broadcast .= '</font><br>';

            
    $broadcast .= '<font color="#df12df" size="12"><b>';    
    $broadcast .= createmailto(createLink(mysql_result($result,$num_of_rows,"body")))'<br><br>';
             
    $broadcast .= '</b></font>';

    }
    print 
    "&fla_body=" .urldecode($broadcast); 
    Last edited by zeroked; 01-03-2003 at 12:24 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center