Last reviewed: 12/1/2001
Article ID: H120101
HOW: Creating Macromedia Director movies that speak and listen
The information in this article applies to:
- SpeechKit 3 and higher
SpeechKit 3 includes ActiveX component format of the ChantSR and ChantTTS classes. This enables you to write applications in programming languages that support ActiveX such as Borland Delphi, Microsoft Visual Studio C++, and Microsoft Visual Basic. An ActiveX component host is referred to as an ActiveX container. For example, Delphi, MSVC++, and VB IDEs and runtimes are ActiveX containers that enable your code to access the ActiveX components. ActiveX containers operate in 2 states: Design and UserMode (run). ActiveX components can query the container for its state to determine if the end-user is coding in the IDE or running the application.
Since Director does have an IDE in which you construct your movie, there is a property palette in which you can set component property values. However, Director does not perform it's property exchange as an ActiveX container in UserMode (run) state and this requires you to set property values in your Lingo code instead.
You must also ensure in Director that your movie timeline does not loop. You may have frame loops but you don't want your movie to loop to the beginning and replay. The reason is that this causes the component to be freed at the end of your movie and reallocated at the beginning. Component processing is interrupted and terminated at the end of the movie because the component is released. Speech recognition and synthesis is therefore terminated. Use "go to me" on an exitframe event to loop within a frame to keep you movie running until it's time to end your movie.
Even though you have started your movie in Director, not all events fired are in UserMode (run) state. For example, Lingo code that sets properties or invokes methods on the components is not executed in events such as startMovie, stopMovie, prepareMovie, and beginSprite because Director is still in Design state when these events fire. However, Lingo code that sets properties or invokes methods on the components in events such as mouseup, mousedown, enterFrame, and exitFrame does get executed.
Enabling your movie to listen for commands or speak requires that you ensure your movie does not loop to the beginning of its timeline. This is because the ActiveX components are allocated and initialized (instantiated) at the beginning of the movie. You sustain their existence and ability to receive event notifications if you loop in movie frames later in your timeline. Then you can exit your movie as needed or at the end of your time line or when appropriate.
You can place your ActiveX components on any sprite. You set properties or invoke methods on the components in your Lingo code by referencing the Sprite number. If you want to use the enumeration constants to pass as parameter values like other tradition programming languages, then you need to define these constant values as globals. See the Saythis sample for an illustration of this.