views:

195

answers:

1

A have a flash widget (a music player) and there are about 10 instances of it on one page. I need to communicate between the flash and the javascript of the page it's embedded in. I haven't done much with actionscript for a long time, but some googling led me here, and to ExternalInterface. It seemed perfect, however there is one problem. I did something like this:

ExternalInterface.addCallback("stopTrack", this, stopTrack);

However, now stopTrack will be registered to 10 different things on the page. I want to be able to stop just one of the 10 tracks.

+2  A: 

I don't ENTIRELY remember -- but I seem to think that the callback isn't added to the window object, but the swf object on the page -- so somthing like

document.getElementById('musicFlashPlayer10').stopTrack();

would fire the callback on only that instance.

This format might change between browsers - in any case, the callback is added to each javascript instance the flash file is loaded for.

Robert