Solved

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

Posted on 2006-10-28
7
816 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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.
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now