all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

need to load database data into flash thru php


need to load database data into flash thru php juicefif
2/1/2006 10:02:22 PM
flash actionscript:
I'm redesigning a site i did for a band and i would like to do it all in flash
but i don't know how to load php into flash. I need to load in their news and
tour dates into a scrolling textbox. Here's what I had when it was html:

The PHP:
<?

require('DB.php');
require('Smarty.class.php');

$dsn = array(
'phptype' => 'mysql',
'hostspec' => 'localhost',
'database' => 'storysideb',
'username' => 'storysideb',
'password' => 'he3Dogee'
);

// initialize Smarty object
$smarty = new Smarty;
$smarty->template_dir = '.';
$smarty->compile_dir = 'templates_c';

// connect to database
$dbh = DB::connect($dsn);

// snarf data
$smarty->assign('array_tour', $dbh->getAll('SELECT * FROM tour ORDER BY date
DESC', DB_FETCHMODE_ASSOC));

// display page (for now)
$smarty->display('tour.html');

The HTML:
<ul>
{section name=i loop=$array_news}
<li><strong>{$array_news.date}</strong><br >
<em>{$array_news.headline}</em><br />
<p>{$array_news.details}</p>
</li>
{/section}


<ul>
{section name=i loop=$array_news}
<li><strong>{$array_news[i].date}</strong><br >
<em>{$array_news[i].headline}</em><br />
<p>{$array_news[i].details}</p>
</li>
{/section}
Re: need to load database data into flash thru php sampurtill
2/3/2006 8:44:33 PM
You have to use the LoadVars class in Flash. Use LoadVars.sendAndLoad and load
your PHP script. You must return values from the php script into flash, so I
believe that's echo or something in PHP, not sure cause I use CF. But make sure
you return it as a variable into flash and then you can parse that data.

Sam
AddThis Social Bookmark Button