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!
Contacts
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
  ie=xtra("VbScriptXtra").CreateObject("InternetExplorer.Application")
  
  -- Checking whether object is created
  if not objectP(ie) then
    alert "Failed to create InternetExplorer.Application:"&RETURN&ie
    exit
  end if
  
  -- Navigate to URL
  ie.navigate(url)
  
  -- hiding extra interface elements
  ie.menubar=false
  ie.toolbar=false
  ie.statusbar=false
  
  -- Adjusting Internet Explorer window rect
  if voidP(displayRect) then
    ie.fullScreen=true
  else
    ie.width=displayRect[3]-displayRect[1]
    ie.height=displayRect[4]-displayRect[2]
    ie.left=displayRect[1]
    ie.top=displayRect[2]
  end if
  
  -- Waiting while page is completed
  start=the ticks
  seconds=0
  repeat while ie.readyState<ie.GetEnum(#READYSTATE_LOADED)
    time=the ticks
    if (time-start)/60 > seconds then
      seconds=(time-start)/60
      put "Waiting for IE:"&&seconds&&"sec(s)"
    end if
  end repeat
  
  -- Here we are, ready!
  ie.visible=true
  put "Ops IE is ready!"
end

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
  me.GoHome()
end

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

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

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

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

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

    #CommandStateChange:
      -- do nothing
      -- put event,args

    #NewWindow3:
      -- 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] )

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

-- Makes IE to go back in history
on GoBack me
  mIE.GoBack()
end

-- Makes IE to go to our starting page
on GoHome me
  member("TitleText").text = ""
  mIE.Navigate("www.xtramania.com")
end

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