Solved

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

Posted on 2006-10-28
7
844 Views
Last Modified: 2008-02-26
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.
0
Comment
Question by:Aspirin99
  • 4
  • 3
7 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17826459
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
0
 
LVL 1

Author Comment

by:Aspirin99
ID: 17826801
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".
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17828025
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17828066
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
0
 
LVL 1

Author Comment

by:Aspirin99
ID: 17828521
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.
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 500 total points
ID: 17828534
You can create variables at root using these values..

for example:

function makeCall(param1, param2,param3){

_root.var1 = param1;
_root.var2 = param2;
_root.var3 = param3;

}
-----------

now you can use these _root variables as you want...
0
 
LVL 1

Author Comment

by:Aspirin99
ID: 17828686
THanks, I'll work with that.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Action Script commands 5 248
Video sharing with user login 3 215
HTML 5 video and audio or Flash 1 68
Some You tube not working in IE11 on Windows 10 and 8.1 5 95
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question