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 524161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:32:19+00:00 2026-05-13T08:32:19+00:00

Im trying to use JS to send data to my Flash AS2.0 music player

  • 0

Im trying to use JS to send data to my Flash AS2.0 music player with ExternalInterface, except there are no good tutorials or guides on ExternalInterface that I can find. I want to be able to change the current song in the player by clicking a JavaScript link, and on page / window load without clicking, play a default song.

I dont need a super complicated answer on loading sounds in flash, etc., I am just having a lot of difficulties getting JS to send anything to Flash, and when I get that to work – would I need to put some if / else into the flash to determine if the link has been clicked or not?

Thanks

edit heres the code as of now:

AS 2.0

import flash.external.ExternalInterface;

ExternalInterface.addCallback('loadSong', null, flashFunction);

function flashFunction (val) {
    extra = val;
}

JavaScript

var flashObj = document.getElementById('VSPLAYER');

function loadSong(val) {
    return val
}

HTML

<a href="javascript:loadSong('2')">Play song 2</a>

<object id="VSPLAYER" type="application/x-shockwave-flash" data="vs_player.swf" width="280" height="90">
<param name="movie" value="vs_player.swf" />
<param name="allowscriptaccess" value="always" />
</object>
  • 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-05-13T08:32:19+00:00Added an answer on May 13, 2026 at 8:32 am

    In your Flash, preferably in the first frame, put this:

    ExternalInterface.addCallback('callFlashFunction', null, yourFlashFunction);
    
    function yourFlashFunction (arg1, arg2) { ... }
    

    In your Javascript, you can call it via:

    var flashObj = document.getElementById ('FlashObjID');
    flashObj.callFlashFunction (arg1, arg2);
    

    If your SWF is in a different domain, remember to allow script access via:

    <object id="FlashObjID"> ... <param name="allowscriptaccess" value="always" /> ... </object>
    

    Update (based on your HTML):

    <a href="#" onclick="return jsLoadSong('2')">Play song 2</a>
    
    <object id="VSPLAYER" type="application/x-shockwave-flash" data="vs_player.swf" width="280" height="90">
        <param name="movie" value="vs_player.swf" />
        <param name="allowscriptaccess" value="always" />
    </object>
    
    <script type="text/javascript">
        var flashObj = document.getElementById ('VSPLAYER');
        function jsLoadSong (val)
        {
            flashObj.loadSong (val);
            return false; // to prevent default link action
        }
    </script>
    

    I tried to clarify the names to show which is in Javascript, and which is tied to the Flash. Also note that you’d need to wait till the DOM is loaded before calling defining flashObj. here, the <script> tag is after the <object>, so it will work fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a game that sends game play data to a rails
I'm trying to type-check the commands I want to send to a server from
I'm trying tu use Jeditable to edit inline some content put in textareas. So,
I'm building a little MMORPG and im trying to use asyncore rather then threading.
I am trying to get a good grasp of UDP on Android, so I
I'm trying to send an integer over the serial port to my Ardunio. The
I am trying to use JSON for getting dynamic content to my webpage, using
I currently have some code which iv used to export a table from the
I need to call a servlet call for an automation of a java applet
I feel like I'm doing this wrong, or it's just a result of my

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.