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('variabl e01')" >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.
<p>1. <a class=Uline href="javascript: void();" onclick="makeCall('variabl
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.
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
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
--------
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
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THanks, I'll work with that.
for example:
makeCall('var1','var2',var
in flash, read as many parameters as you have send through html..
Regards
Aneesh