As the title says I am loading a flash in my webpage and when I call LoadVars() it crashes the web page.
Here is my code:
Flash
lv = new LoadVars();
lv.onLoad = onLoadCallBack;
lv.load("php/flash_getitems.php");
function onLoadCallBack(succes){
if(succes){
t = lv[this.totalItems];
for(i = 1; i<= t; i++){
key = this.itemName + "" + i;
itemList.addItemAt(i, key);
}
}
}
stop();
php
INCLUDE 'connector.php';
$query = mysql_query("SELECT * FROM shop");
$totalrows = mysql_num_rows($query);
echo "&totalItems=$totalrows";
while($row = mysql_fetch_assoc($query)){
$id = $row['id'];
$item = $row['item'];
$desc = $row['description'];
$price = $row['price'];
echo "&itemName$id=$item";
echo "&price$id=$price";
echo "&desc$id=$desc";
}
This will return values like this
&itemName1=First Item&price1=100&desc1=description
and so on so forth with the higher id's
It looks to me like your parsing function has a couple of syntax errors.
See if this works any better:
function onLoadCallBack(success){
if(success){
for(var i:Number = 1; i<= lv.totalItems; i++)
itemList.addItemAt(i, lv["itemName"+i]);
}
}
lv["itemName"+i]
will evaluate to lv.itemName1
, etc. You tried to access undefined variables, which causes a null reference error.