Section2: DA Events via VBScript Buttons
We start with the applet tag which centers the puzzle at the begining of the html page. Notice the use of the ID parameter to give the applet a label that gets used in VBScript. All public methods in the applet are visible to VBS (or JScript) scripting.

| <CENTER> <APPLET CODE="FifteenPuzzle.class" CODEBASE="../../../../../media/" ID=fifteenPuzzleApplet
WIDTH=300
HEIGHT=300
ALIGN=CENTER
VSPACE=20>
</APPLET>
</CENTER>
We use three VBScript buttons:
1) for switching the mode of the puzzle from 2D to 3D and back,
2) for cycling through different images for the puzzle,
3) for reseting the puzzle to it's original image and state.
We first declare the buttons.

| <CENTER> <input type=button value="3D Puzzle" name="toggleProjectionButton"> <input type=button value="Donuts" name="toggleImageButton"> <input type=button value="Reset Puzzle" name="resetPuzzle"> </CENTER>
We then use VBS as the glue between the buttons and the applet. Essentially each button invokes a corresponding subroutine below where the subroutine calls a corresponding public method in the applet and modifies the labels on the buttons as appropriate.

| <script language="VBScript"> <!-- sub toggleProjectionButton_OnClick document.fifteenPuzzleApplet.toggleGeomProjection if toggleProjectionButton.value = "3D Puzzle" then
toggleProjectionButton.value = "2D Puzzle"
else
toggleProjectionButton.value = "3D Puzzle"
end if
end sub
sub toggleImageButton_OnClick
if toggleImageButton.value = "Donuts" then
toggleImageButton.value = "Movie"
elseif toggleImageButton.value = "Movie" then
toggleImageButton.value = "Movie with Counter"
elseif toggleImageButton.value = "Movie with Counter" then
toggleImageButton.value = "Counter"
else
toggleImageButton.value = "Donuts"
end if
document.fifteenPuzzleApplet.toggleImageUsed
end sub
sub resetPuzzle_OnClick
document.fifteenPuzzleApplet.resetPuzzle
toggleImageButton.value = "Donuts"
end sub
-->
</script>

These are DXMApplet public methods that are visible to VBScript and are used as conduits for VBScript button events to triggering AppTriggerEvents in DirectAnimation.

public void toggleGeomProjection() { _model.toggleGeomProjection(); }
public void toggleImageUsed() { _model.toggleImageUsed(); }
public void resetPuzzle() { _model.resetPuzzle(); }

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.