Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9173741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:38:09+00:00 2026-06-17T16:38:09+00:00

I’m trying to send a simple test message from javascript to flash, but I’m

  • 0

I’m trying to send a simple test message from javascript to flash, but I’m getting the error:

Object #<HTMLObjectElement> has no method "listenToJS"

I’ve read a number of questions on this on stack, but I feel like either the browser is not getting the proper reference to my flash object, or within my actionscript I am not putting my flash function in the proper place.

So within html I am embedding flash with SWFObj:

<div id="flash_content">
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1280" height="800" id="tourFlash" name="pano" class="pano">
        <param name="movie" value="VRDemo.swf" />
        <param name="menu" value="false" />
        <param name="wmode" value="transparent" />
        <param name="allowscriptaccess" value="always" />
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="VRDemo.swf" width="1280" height="800" class="pano">
            <param name="menu" value="false" />
            <param name="wmode" value="transparent" />
            <param name="allowscriptaccess" value="always" />
            <param name="allownetworking" value="all" />
            <param name="flashvars" value="zoom=null&amp;pan=null&amp;sound=null" />
        <!--<![endif]-->
            <a href="http://www.adobe.com/go/getflashplayer">
                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
            </a>
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
    </object>
</div>

<script>

var flashObj; 

$(document).ready(function(){

    flashObj = document.getElementById('tourFlash');

    $('#interface').click(function(){
        console.log('click');
        talkToFlash();
    });
});

function talkToFlash(){
    flashObj.listenToJS('hello from js');
}

function listenFromFlash(flashMessage){
    console.log(message);
}
</script>

The click handler is triggered, but here I get the error. My flash file uses a document class, and within the document class is the public function. Flash is structured like this:

package com.company.vr {

    import flash.display.*;
    import flash.events.*; 
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.external.ExternalInterface;
    import flash.system.Security;

    Security.allowDomain("*");

     public class VR_TestDocument extends MovieClip {
            public function VR_TestDocument() {
              ExternalInterface.addCallback("talkToFlash", listenToJS);
            }


            public function listenToJS(message){
              trace ("from js: " + message);
              var flashMessage = message + " flash";
              ExternalInterface.call("listenFromFlash", flashMessage);
            }
     }
}

—UPDATE—

It looks like External Interface doesn’t like SWFObject for some reason. If I switch to the method of embedding that Flash used in this example:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html#addCallback()

it works, but I feel like swfobject is the best way to embed flash. Anyone got any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:38:11+00:00Added an answer on June 17, 2026 at 4:38 pm

    If you embeded flash in html as your code above, note, that second tag object also has to contain attribute id, corrected code is here:

    <div id="flash_content">
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1280" height="800" id="tourFlash" name="pano" class="pano">
        <param name="movie" value="VRDemo.swf" />
        <param name="menu" value="false" />
        <param name="wmode" value="transparent" />
        <param name="allowscriptaccess" value="always" />
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="VRDemo.swf" width="1280" height="800" class="pano" id="tourFlash1">
            <param name="menu" value="false" />
            <param name="wmode" value="transparent" />
            <param name="allowscriptaccess" value="always" />
            <param name="allownetworking" value="all" />
            <param name="flashvars" value="zoom=null&amp;pan=null&amp;sound=null" />
        <!--<![endif]-->
            <a href="http://www.adobe.com/go/getflashplayer">
                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
            </a>
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
    </object>
    

    But of course, swfobject is the best way to embed flash. Correct html code looks like:

        <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
        <head>
            <title>js</title>       
            <script type="text/javascript" src="swfobject.js"></script>
            <script>
                function talkToFlash(){
                    document.getElementById('flash_content').listenToJS('hello from js');
                }
    
                var flashvars =  {};
                var params = {
                    allowscriptaccess: "always"         
                }           
                var attributes =  {};
                swfobject.embedSWF("VRDemo.swf", "flash_content", "550", "400", "10.0.0", false, flashvars, params, attributes);
        </script>   
        </head>
        <body>
            <div id="flash_content"></div>
        </body>
    </html>
    

    –Update–

    You have to select the correct flash element on the page. (Depends on the browser). As an example, here is code to get correct flashObj:

    flashObj1 = document.getElementById('tourFlash');
    flashObj2 = document.getElementById('tourFlash1');
    flashObj = flashObj1.talkToFlash != undefined ? flashObj1 : flashObj2;      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.