views:

979

answers:

4

I would like to pass over 50 items of variables from php to flash. Actually I want to pass array with foreach statement, looping through the array and assigning loop index to the variables and flash again accept the php values through looping. Is this possible?

If passing values through foreach or loop statement is impossible, I would like to break a new line in tag. how can I break a new line in FlashVars tag?

+2  A: 

You can pass the values as a comma separated string (provided the values doesn't have commas, of course) - that way you can make them into an array in flash using string.split(",");

Amarghosh
Thanks a lot, Amarghosh!I pass string by imploding array in php and use split() in flash.the main problem is that the params I'm sending to flash are over 20. So I want to break a line for <Param Name=FlashVars Value="....">tag. I tried to use two FlashVars tags but only first line of FlashVars can be retrieve in flash. how can I do??plz forgive me if my question is so stupid. I'm really lost!!thanks for ur help.
SoeTheingiLin
Afaik, you cannot have more than one flashvars. What's wrong about number of params being over 20? does it break or are you just concerned about the readability of the html code thus generated?
Amarghosh
A: 

If you feel that this is pushing flashvars beyond its limit you might consider making an HTTP request back to your PHP page from within the SWF and send it whatever data you want.

Simon
A: 

with that many tags you might consider using a URLLoader or ExternalInterface call to get the information from a function or page, otherwise you can just push a list together something like this: presuming $vararray is the array of vars you want to pass

PHP:
    $flashvars = "";
    $init = true;
    for($i = 0; $i<count($vararray); $i+=1){
    if($init == true){
    $init=false;
    }
    else{
    $flashvars.=&
    }
    $flashvars.="var$i=".$value;
    }

then use the $flashvars string for the flashvars embed and run through the loaderInfo.Parameters array in flash

shortstick
A: 

Or honestly just use XML - that's probably the best way to load in that many variables.

Myk