?
Solved

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

Posted on 2006-10-28
7
Medium Priority
?
855 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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 …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

801 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