title: Can a JavaScript function detect which Flash DOM object called it?
body: <p>Here's the challenge: I have a Flash movie which will be embedded in a page using an unknown DOM ID that I want to be able to identify/store for callback in a JS function.</p>
  
  <p>My ideal user flow would be:</p>
  
  <ol>
  <li>User clicks button in Flash.</li>
  <li>Flash pauses any animations / video / sounds / etc.</li>
  <li>Flash calls an injected JS function to display a page-covering overlay experience.</li>
  <li>When user closes overlay experience, a callback method on the Flash object is called.</li>
  <li>Flash resumes playback.</li>
  </ol>
  
  <p>The problem is, when AS3 uses the ExternalInterface.call("functionName", args...) method, there doesn't seem to be a DOM event triggered, and thus it is impossible to tell which object called a JS function, so having a "registerMe()" function doesn't seem to work. Basically, the injected JS function has no way to determine which DOM object to call, because the ID of the Flash object is unknown.</p>
  
  <p><strong>[UPDATE]</strong>
  It turns out, a SWF can determine its own url using loaderInfo.url. I'm passing that information to the script that launches the overlay experience so it can be stored for a future comparison against all application/x-shockwave-flash DOM objects. When a match is found, that is the calling SWF. Does anyone see a flaw in this logic? (I'm not nearly as proficient with JS as I am with AS)</p>