Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : Javascript <--> Flash: communication trouble



automan25
3/3/2004 9:59:44 PM
On my webpage I need to be able to communicate from Javascript to Flash and
vice versa.

To communicate from Flash to Javascript I'm using FScommand.

From javascript to Flash I'm using the flashVars parameter of the Object &
embed tags. I have my page set up to dynamically write the object/embed code to
the DIV tag that I want to contain the flash movie. This is necessary due to
the variables that I'm using in the FlashVars values. The code looks similar to
the following:

var HTMLins = "<OBJECT ID='newsTicker' width='114' height='355'><param
name=movie value='movie.swf'><param name=FlashVars value='recalledBit=" +
parent.upperPanel.activeNewsClip + "'>"
document.getElementById("newsTickerLayer").innerHTML=HTMLins;

This dynamic method of communication from Javascript to Flash works very well
with one exception. It screws up my FSCommand communication. My FSCommand code
used to run great when the object & embed tags were actually coded into the
page. Now that the page is set up to generate the object & embed tags
dynamically as mentioned above, the FSCommands don't want to work at all.

Any ideas?
Laiverd.COM
3/4/2004 1:17:21 AM
Actually; there's no need to use FScommand at all. Here's a simple example
of what I once created:
http://home.hccnet.nl/john.mulder/flash/js_comm.zip

But actually - unless you insist on publishing for Flash Player 5 or
earlier - it's well worth to have a look at Local Connection Object, which
is much more reliable. After all the simple action of turning of javascript
in the browser would sabotage whatever you're trying to achieve.

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

automan25
3/4/2004 5:43:38 PM
I examined your code. It seems to work very well. I won't work for my project
though. I chose to use FScommand because it eliminates that "click" noise that
IE produces every time you click on a link. That same click occurs when you use
the GetURL command from Flash. Since my script will be sending data to the page
twice every second the clicking noise would get rather annoying to the user.

You did mention creating the Local Connection Object though. Since I have
another flash movie on the site I can use Local Connection Object to store data
in the other flash movie rather than in the webpage itself, thus solving my
problem.

Thanks for the help.
AddThis Social Bookmark Button