javascript-flash communication

Can anyone tell me if there are any other alternatives for javascript to communicate with a flash file other than using the setVariable() method as a flag to call flash methods? Also, does anyone know of how I could cache my processing so that javascript will wait for flash and vice versa?

blu.
 
LVL 39
blue-genieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rexmorCommented:
how about localConnection.. http://www.macromedia.com/support/flash/ts/documents/localconnection.htm

or SharedObjects...
0
blue-genieAuthor Commented:
Hi Rex. it's my colleague asking this question.
he's a java programmer, what he's basically wants to know is, can you use javascript to call a method in flash, and if yes, how would you do this.

blu.
0
andreas_dCommented:
here is my way

see this how to properly embed the movie : http://www.moock.org/webdesign/flash/fscommand/#javascripttoflash

i think it is not possible to call a method directly in flash. therefore i use a setter function to transport the parameters and a getter function to fetch the result. (obj.addProperty(n,s,g))
here are my files:
http://home.pages.at/andreas-deschka/xy.fla
http://home.pages.at/andreas-deschka/xy.html

<script language="javascript">
var cf=function(fn){
      var r= new Array();
      for(var i=0; i< arguments.length-1; i++){
            r.push(arguments[i+1]);
      }
      document.xy.SetVariable(fn, r.join(";"));
 // i pass the arguments converted to a string
      return document.xy.GetVariable(fn);
}      
</script>
<a href="javascript:alert(cf('obj.multiply',45,3));">click</a>

Andreas
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

negatyveCommented:
Yep, there is. Use SetVariable to pass arguments, and TCallLabel to invoke the script (pseudo function call):

http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html#70479
0
blue-genieAuthor Commented:
neg.

Glad you're around, I told my colleague if any one can answer this it would be you.

What he's trying to do is, using Javascript, calls a method in Flash, its not parsing anything to the Flash, the Javascript must then wait for a return value from the flash method, before it proceeds with anything else.

Can this be done, can you help with an example?
Many thanks,
blu.

0
negatyveCommented:
Hi, blue.. :)

Well, I think that you could use Object.watch to look for changes on a variable in flash, but not the same by javascript side. I think you should go with simple function calls:

- javascript set a variable in flash, then call the function (SetVariable + TCallLabel)
- flash, when done, calls back javascript (getURL("javascript:function(parameters)");)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
blue-genieAuthor Commented:
Ok, thanks neg.

We're gonna work on it for a while and I'll get back to you.

It makes sense.

blu.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.