Cari tutti,
sto cercando di fare parlare un db mysql con uno scroll per news in flash. Utilizzo per questo uno script PHP e credo sia corretto.
Solo che non riesco assolutamente (mentre tutto funziona se a essere richiamato è un .txt)
questo lo script php per estrarre i valori da mysql:
<?php
$host = 'host'; # l'host in cui risiede il database (IP)
$user = 'user'; # la username per accedere al database
$pass = 'pass'; # la password per accedere al database
$db = 'db'; # il nome del database
mysql_connect($host,$user,$pass); #connessione al database
mysql_select_db($db); #selezione al database
$tot = 5; # il numero di news da visualizzare ogni volta
$i = 0; # variabile che serve da indice (da incrementare)
$query = "SELECT id,titolo,testo,DATE_FORMAT(data, '%d.%m.%Y') as newData
FROM news
ORDER by data desc
LIMIT 0,$tot";
$result = mysql_query($query);
$output = 'tot='.mysql_num_rows($result);
while($news = mysql_fetch_array($result))
{
$output .= '&data'.$i.'='.$news['newData'];
$output .= '&id'.$i.'='.$news['id'];
$output .='&Title'.$i.'='.urlencode($news['titolo']);
$output .='&myText'.$i.'='.urlencode(substr($news['testo'],0,200));
$i++;
}
echo $output;
?>
quindi il file flash che ha due livelli. Questo il codice nel primo livello:
// Creo un nuovo LoadVars Object
myData = new LoadVars();
// questo dice che funzione invocare quando la Load Vars è completa.
myData.onLoad = addItems;
// questo è il collegamento al file php.
myData.load("news.php");
questo il codice nel secondo livello:
function addItems() {
// Seleziono il titolo dal file php.
Title = myData.Title;
// Seleziono alcune proprietà.
myText.multiline = true;
myText.wordWrap = true;
myText.type = "dynamic";
myText.background = true;
myText.backgroundColor = "0x000000";
myText.border = false;
myText.html = true; // Enables HTML in the text field.
// Setto il testo per il campo testo.
myText.htmlText = myData.myText;
ScrollBar.setScrollTarget(myText);
// applico uno stile allo scroll.
formStyleFormat = new FStyleFormat;
formStyleFormat.scrollTrack = "0x000000";
formStyleFormat.highlight = "0x000000";
formStyleFormat.highlight3D = "0xffffff";
formStyleFormat.arrow = "0xffffff";
formStyleFormat.face = "0x000000";
formStyleFormat.background = "0x000000";
formStyleFormat.shadow = "0x666666";
formStyleFormat.darkshadow = "0x333333";
// Applico i cambiamenti.
formStyleFormat.addListener(ScrollBar);
formStyleFormat.applyChanges();
// Setto alcune altre opzioni
textFormat = new TextFormat();
textFormat.color = "0xffffff";
textFormat.bullet = false;
textFormat.underline = false;
textFormat.bullet = false;
textFormat.size = 11;
textFormat.font = "arial";
// Setto il formato testo
myText.setTextFormat(textFormat);
}
Questo è quanto...
Qualcuno sa come farlo funzionare?
vi ringrazio in anticipo!