Link to home
Start Free TrialLog in
Avatar of Aspirin99
Aspirin99

asked on

Flash 8, ExternalInterface API - How to pass multiple variables?

I use Flash 8's External Interface API to pass variables back and forth between HTML and Flash. Here's a sample of the HTML:

<p>1. <a class=Uline href="javascript: void();" onclick="makeCall('variable01')" >Send variable01 as a string to the Flash movie</a>

Obviously, I could send a several variables separated by some special character, send it to an array and split it on that character to get more variables, but it seems there may be an easier way.  Like, with FlashVars, which allows you to separate the variables with "&".  

Please respond if you have specific experience with Flash's externalInterface API. Thanks.
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

you can simply send multiple variables as multiple parameters to function,

for example:

makeCall('var1','var2',var3')

in flash, read as many parameters as you have send through html..

Regards
Aneesh
Avatar of Aspirin99
Aspirin99

ASKER

Right, that's pretty much what I meant when I said, "Obviously, I could send a several variables separated by some special character, send it to an array and split it on that character to get more variables".
sorry, here comma is not a seperator character, all variables here are seperate parameter which are not joint at all,
a function can have 'n' number of parameters
you can loop through function arguments using following code:
--------
function fnTest()
{
      for (var i = 0; i<arguments.length; i++)
      {
            trace(arguments[i]);
      }
};
fnTest(1,2,3,4,5);
----------
this way you can pass dynamic number of arguments to any function..


Rgds
Aneesh
Thanks, Aneesh. What I don't understand is how to use this once it is passed into Flash. It is passed as a string without being assigned as a variable. Whereas, FLashVars allows me to assign a variable such as myFile=filename.mp3. I was hoping for something similar to that.
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
THanks, I'll work with that.