Interacting with the browser

Starting Parameters

The OBJECT and EMBED tags used to embed Shockwave have 9 optional parameters called "sw1" through to "sw9". When shockwave starts, we can read these parameters using the externalParamValue lingo function like this:


on GetExternalParameters ()
 externalParameters = [:]
 mx = externalParamcount() 
  if mx > 1 then   
    repeat with i = 1 to mx
      n = externalParamName(i)
      v = externalParamValue(i)
      externalParameters.addProp(n,v)
    end repeat
  end if 
  return externalParameters
end

This is particularly useful if you are using a CMS or server-side scripts to write out the Shockwave embed tags and you want to specify certain parameters for Shockwave.

Communcating while Shockwave is playing

To call a javascript function contained with a webpage from Shockwave, you can use goToNextPage netLingo function, like this:


on SendMessageToBrowser ( aParameter )
  goToNetPage("javascript:VOID(ShowMessage('"&aParameter&"'))")
end

To receive a message sent by Javascript in a browser, Lingo provides the evalscript function. Basically, Javascript calls the EvalScript method of the Shockwave object and in the Shockwave movie, you write a on EvalScript function to handle the message. However, EvalScript doesn't work with Safari or Firefox. If you have Director MX2004, then you can use Director's Javascript and a flash object to communicate with the browser. See Valentin's adaption of " JavaScript Integration Kit" for Director Shockwave (actually, for anything you get stuck with, you should have a look at Valentin's site).

Last updated 19th of July, 2006

© 2006 MeccaMedialight. Site Powered by Wrangler 8.