SoeTheingiLin
SoeTheingiLin

Reputation: 1

Using FlashVars to pass variables to a SWF

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?

Upvotes: 0

Views: 2125

Answers (4)

Myk
Myk

Reputation: 6215

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

Upvotes: 0

longstaff
longstaff

Reputation: 2051

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

Upvotes: 0

Simon
Simon

Reputation: 80769

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.

Upvotes: 0

Amarghosh
Amarghosh

Reputation: 59451

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(",");

Upvotes: 2

Related Questions