A list of products available on this site
Documentation for XtraMania's xtras
Prices and links to the online store
Xtras, PDFs, samples
Have a question? Ask us!
Logo. www.xtramaina.com  
Home Search E-mail
VbScriptXtra Samples/Internet Explorer

ActiveCompanionSet xtras for Macromedia Director

Silent navigation to url

This handler runs hidden Internet Explorer application, tells him to navigate to URL, waits while IE is ready and then makes it visible.

on Navigate url, displayRect
  if voidP(url) then url="www.XtraMania.com"
  -- Creating a new instance of Internet Explorer
  -- Checking whether object is created
  if not objectP(ie) then
    alert "Failed to create InternetExplorer.Application:"&RETURN&ie
  end if
  -- Navigate to URL
  -- hiding extra interface elements
  -- Adjusting Internet Explorer window rect
  if voidP(displayRect) then
  end if
  -- Waiting while page is completed
  start=the ticks
  repeat while ie.readyState<ie.GetEnum(#READYSTATE_LOADED)
    time=the ticks
    if (time-start)/60 > seconds then
      put "Waiting for IE:"&&seconds&&"sec(s)"
    end if
  end repeat
  -- Here we are, ready!
  put "Ops IE is ready!"

Using InternetExplorer ActiveX control right on the Stage

This sample uses both ActiveX xtra and VbScriptXtra from ActiveCompanionSet.

ActiveX xtra from ActiveCompanionSet is similar to the native Director ActiveX support except one important thing. It provides advanced scripting support via VbScriptXtra.

For example ActiveCompanionSet allows using InternetExplorer ActiveX for on stage web browsing will full control of IE actions via IE events. The sample below shows how to prevent user from opening new IE windows and thus leaving Director application. It could be useful for kiosk applciations for example.

Below is the code of behavior that should be placed on IE ActiveX sprite:

property spriteNum

property mIE

on beginSprite me
  sprite(spriteNum).debugMode = true

  -- Trying to get Automation object for IE ActiveX control
  mIE = sprite(spriteNum).GetObject()

  -- Set me to be the event handler for IE
   mIE.EventsHandler = me

  -- Navigate to the start page

on endSprite me
  -- Make sure to reset event handler
  mIE.EventsHandler = VOID

  -- Clear the title member
  member("TitleText").text = ""

-- Generic events handler called by VbScriptXtra when any IE event is detected
on IncomingEvent me, event, args
  case event of
      -- Update status text
      member("StatusText").text = args[#Text]

      -- Update title
      member("TitleText").text = args[#Text]

      -- We can show some progress bar here
      -- put event,args

      -- do nothing
      -- put event,args

      -- We do not wnat user to be able opening new IE window,
      -- so we cancel operation and simply make the
      -- current IE to navigate to the requested page
      args[#Cancel] = #true
      put "Navigate to: " & args[#bstrUrl]
      mIE.Navigate( args[#bstrUrl] )

      -- Put other events to Messages window just to look at them
      put event,args
   end case

-- Makes IE to go back in history
on GoBack me

-- Makes IE to go to our starting page
on GoHome me
  member("TitleText").text = ""

In this sample mIE is usual VBScriptXtra wrapper. Refer to the VbScriptXtra's documentation for more details.

Sample Director movie is available to download. It allows on stage browsing of XtraMania site.

Where to find more info about Internet Explorer?

VbScriptXtra provides autodocumentation feature allowing you to see what you can do with particular object instance. Just create a recordset object and type in Messages window:
put interface(ie)
put interface(ie.document)

ObjectBrowser xtra - autodocumentation companion for VbScriptXtra - will show all available IE interfaces, methods, properties and enumerations.

ObjectBrowser xtra is a part of ActiveCompanionSet. It is available to Download.

Site homeSearchContact author © Eugene Shoustrov. www.xtramania.com