javascript-flash communication

Posted on 2004-11-18
Last Modified: 2008-03-10
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?

Question by:blue-genie
    LVL 9

    Expert Comment

    how about localConnection..

    or SharedObjects...
    LVL 39

    Author Comment

    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.

    LVL 1

    Expert Comment

    here is my way

    see this how to properly embed the movie :

    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:

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

    LVL 27

    Expert Comment

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

    Author Comment


    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,

    LVL 27

    Accepted Solution

    Hi, blue.. :)

    Well, I think that you could use 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)");)
    LVL 39

    Author Comment

    Ok, thanks neg.

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

    It makes sense.


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    flash cs6 4 329
    Adobe flash player fails to install 12 293
    Missing Plugin for Firefox - Can't View Content 7 149
    flash in chrome 4 48
    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 …
    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…
    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…
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

    728 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