;

PDA

Click to See Complete Forum and Search --> : Bringing data into flash


zeroked
01-03-2003, 05:47 AM
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()*1000000), this);
stop();
below is the phpcode (//flash part) is where it should happen

<?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);

jeroen84
01-03-2003, 05:58 AM
Some notes:
-loadVariables("broadcast.php?"+(Math.random()*1000000), this);
You don't have to make SUCH a large random number. :rolleyes: 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.

zeroked
01-03-2003, 09:28 AM
thanks for the help

//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);