<HTML> 
<HEAD>
<TITLE>DirectAnimation SDK, VBScript sample</TITLE><SCRIPT LANGUAGE="JScript">
<!--
if (window.top.frames.length!=0 && window.top.frames[0].ShowNoButtons!=null)
    window.top.frames[0].ShowNoButtons();
//-->
</SCRIPT>
<!--STRIP_END-->
</HEAD>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->


<BODY BGCOLOR=WHITE TOPMARGIN=15 LEFTMARGIN=20>
<FONT FACE="Verm.na, Arial, Helvetica" SIZE=2> 
<CENTER>
<H1>Issuing Scripting callbacks</H1>
</CENTER>

<FONT FACE="Arial" SIZE=4>
DirectAnimation scripting callbacks are used to 
move an HTML DIV tag.  The buttons, when clicked, exhibit a simple animation
and sound effect, and also call a function that moves the HTML.  
</FONT>

<DIV STYLE="position:relative;left=75;top=10" ID="myText">
<FONT FACE="VERDANA" COLOR=blue SIZE=4>Click on the buttons to move this text</FONT>
</DIV>

<OBJECT ID="leftButtonCtrl"        
   STYLE="position:absolute;left=50;top=250;width=150;height=150"
   CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>

<OBJECT ID="rightButtonCtrl"        
   STYLE="position:absolute;left=250;top=250;width=150;height=150"
   CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
<!--
' Get a pointer to the library
Set m = leftButtonCtrl.MeterLibrary

sub window_onLoad  
  ' Set the font and call makeButton with the parameters
  Set font = m.Font("Arial Black", 14, m.Black)
  Call makeButton( leftButtonCtrl, "moveTextLeft", "Move Left",  font)
  Call makeButton( rightButtonCtrl, "moveTextRight", "Move Right", font)

  ' Start the animation on each control
  leftButtonCtrl.Start()
  rightButtonCtrl.Start()
end sub

sub makeButton(control, callbackFunction, buttonLabel, font)
  ' Import the image and sound
  importBase = "../../../../media/"
  Set buttonBaseImg = m.ImportImage(importBase + "image/gray.jpg")
  Set buttonSnd = m.ImportSound(importBase + "sound/blow1.mp2").Sound.Duration(2)

  ' Make a button image from the text and button base
  Set buttonTxtImg = m.StringImage(buttonLabel, font)
  Set buttonImg = m.Overlay(buttonTxtImg, buttonBaseImg)
  
  ' Create an event that calls back the appropriate script function 
  Set buttonEv = m.LeftButtonDown.ScriptCallback(callbackFunction,"VBScript")

  Set doNothing = m.IdentityTransform2
  Set rotateXF  = m.Rotate3RateDegrees(m.Vector3(.1,1,-.1), 180).Duration(2).ParallelTransform2()   
  Set xf        = m.Until(doNothing, buttonEv, rotateXF).RepeatForever()

  ' Set the image and sound on the control
  control.Image = buttonImg.Transform(xf)
  control.Sound = m.Until(m.Silence, buttonEv, buttonSnd).RepeatForever()
end sub

sub moveTextLeft
   myText.style.left = myText.style.PosLeft - 40
end sub

sub moveTextRight
   myText.style.left = myText.style.PosLeft + 40
end sub
-->
</SCRIPT>
</FONT>
</BODY>
</HTML>
