Solved

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

Posted on 2006-10-28
7
840 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
Download slideshow or picture elements 16 438
Stock Videos 17 338
Google Chrome Blank White Screens 13 302
How do i create a Class that can control the main stage in action script 1 42
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

860 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