The Shockwave ActiveX control may be used to play external Director movie files inside your Visual Basic application. In addition, your application may interact with the Director movie content and user input. This TechNote is designed to cover the fundamental information necessary to write a Visual Basic application that utilizes the Shockwave ActiveX control. The topics covered in this TechNote are:

Setting up the Shockwave ActiveX control for use in Visual Basic

  1. Right click in the Visual Basic toolbox and select Components from the pop-up menu.
  2. In the Components dialog box, locate and check the Shockwave Director Control in the list. If the Shockwave ActiveX control is properly installed and registered, it should appear in the list. If it does not appear in the list, you may attempt to manually locate it by clicking the Browse button and navigating to the location of the Shockwave ActiveX control.
  3. Click OK. A new button should appear in the toolbox that contains the small version of the Director application icon.

Creating an instance of the Shockwave Active control in a Visual Basic form

  1. In the toolbar, click the Shockwave Control button (identified by the small Director application icon).
  2. Position the cursor over the Visual Basic form (it changes to a crosshair cursor), press the mouse button and drag the cursor to define the area of the form the control will occupy. Release the mouse button.
  3. A box will appear in area that was dragged containing the words "Shockwave Director" in a repeating pattern. You can resize the box by dragging one of the handles along its perimeter.

Specifying a Director movie to play

When Director movies are played in a web browser, the SRC attribute of the EMBED tag specifies the name of the movie to load. Similarly, the SRC property of the ActiveX control can be used to specify the path to the movie you wish to play in your application. However, you will want the movie to begin playing AFTER your form has fully loaded. Otherwise, the first few frames of your movie might play before the form loads completely (meaning that they will not be seen by the user at all). To ensure that the movie doesn't begin to play before the form fully loads, specify the value of the SRC property in a Form_Load() subroutine:

  1. Click the View Code button for the form containing the control.
  2. Choose the form in the Object pulldown menu and the load event in the Event pulldown menu. This will create a new subroutine for the load event of the form object.
  3. Assign a fully qualified path to the movie you wish to play to the control's SRC attribute. Here's an example:



    ShockwaveCtl1.SRC = "C:\WINDOWS\DESKTOP\MYMOVIE.DCR"



    In this example, ShockwaveCtl1 is the value assigned to the Name property of the control object, SRC is the property to which we are assigning the path to the right of the assignment operator ( = ). Substitute the value of the Name property for your control object.

Passing messages from Director movies

Director movies may pass one string at a time to Visual Basic by means of the externalEvent lingo command (p. 62 in the Director 6 Lingo Dictionary). While the documentation on this lingo command refers specifically to browser scripting, the externalEvent command will fire an event and pass a single string parameter to Visual Basic. The correct lingo syntax is:

externalEvent "string to pass"

Place the externalEvent lingo commands in your Director movie script whenever you wish to trigger an event for your Visual Basic application to handle. The value of the string to pass is arbitrary and at the discretion of the developer. The only restriction is that the externalEvent command will accept only one string argument. If you need to pass multiple values, either concatenate them into one string using a delimiter that will allow you to separate the values in Visual Basic OR use multiple externalEvent statements to pass the values separately. You may use lingo variables to concatenate or assemble the string to pass as an argument to the event.

Receiving Messages from Director movies in VB

  1. Click the View Code button for the form containing the control.
  2. Choose the control name in the Object pulldown menu and the ExternalEvent event in the Event pulldown menu. This will create a new subroutine for the ExternalEvent event of the control object:
    Private Sub ShockwaveCtl1_ExternalEvent(ByVal bstrEvent As String) End Sub
  3. Compare the value passed in to the bstrEvent variable with literal values using if-then-else statements or a case statement. Write statements to perform the desired actions when a specific message is received from the movie played by the control. Example:
Private Sub ShockwaveCtl1_ExternalEvent(ByVal bstrEvent As String)   If bstrEvent = "start" Then   tMovieStatus.Text = "Playing"  End If End Sub

Passing messages to Director movies from Visual Basic

Messages may be passed to a Director movie by use of the ActiveX control's EvalScript function. Like the externalEvent lingo command, the EvalScript function passes a string argument to the Director movie for handling. To execute the EvalScript function from within a subroutine in VB, type the name property of the control object, a period, EvalScript, a space and the string to pass to the Director movie:

ShockwaveCtl1.EvalScript "blue hyaena"

Receiving messages in Director movies

Messages passed to a Director movie are handled by the lingo on EvalScript handler. This handler should be placed within a movie script in order to be made available to the entire movie. When the EvalScript function is called from Visual Basic, the Director movie receives notification of the event and passes the string argument to the on EvalScript handler. If the string passed is a valid lingo statement, use the lingo do command to evaluate the string expression and execute the lingo statement it contains:

on EvalScript myArgument   do myArgument end

If the string passed is not a valid lingo statement, use if-then statements or a case statement to determine whether the string contains a known value and execute the desired lingo statements accordingly. An example on EvalScript handler that employs this strategy would look like this:

on EvalScript myArgument   if myArgument = "blue hyaena" then     go to Movie "blue_hyaena.dir"   else     if myArgument = "red hyaena" then       go to movie "red_hyaena.dir"     else       nothing     end if   end if end

Controlling Director movies from Visual Basic

The Shockwave ActiveX control makes a custom set of properties and methods available to Visual Basic. Properties may be set in Visual Basic by specifying the name of the control object, a period, and the name of the property in an assignment statement:

ShockwaveCtl1.AutoStart = TRUE

The control may also be directed by Visual Basic to execute one of its provided methods by specifying the name of the control object, a period, the method and any required argument list:

ShockwaveCtl1.GotoMovie(http://www.mydomain.com/shockwave/myDirMovie.dcr)

For more information on the properties, methods and events the Shockwave ActiveX control makes available to Visual Basic, see Shockwave for Director ActiveX Control Documentation.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy