JS and Flash cross interaction

Setup:
index.html - with a flash object that has a button “Pick Image”, that calls a popup (gallery.html)
gallery.html - just a list of images, when called by clicking the button in index.html it should run a function in the flash object in index.html

Example:

  1. Click on “Pick Image” button on index.html
  2. gallery.html pops up
  3. User selects an image
  4. Call to index.html and a funciton in the flash object there

Can it be done? I know that there is Flash JS interaction within one document, but what about 2? I’ve found different ways to communicate between Flash&JS, but I didn’t see it being done in two different documets (htmls).