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:
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.
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:
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.
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.
Private Sub ShockwaveCtl1_ExternalEvent(ByVal bstrEvent As String) If bstrEvent = "start" Then tMovieStatus.Text = "Playing" End If End Sub
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"
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
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:
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.