How to Create a JScript Animation

The Microsoft® DirectAnimation® library works with the DirectAnimation integrated-media control (DAViewerControl). Library calls are made through a scripting language, such as Microsoft® JScript® or Microsoft® Visual Basic® Scripting Edition (VBScript), to construct an animation and play it from an HTML file.

The following steps show how to construct a simple DirectAnimation control in JScript.

  1. In your HTML file, declare your DAViewerControl object. The object's name can be anything. Here, it is called DAControl. The CLSID must be as shown:
    <DIV ID=controlDiv>
    <OBJECT ID="DAControl"
        STYLE="position:absolute; left:10; top:10;width:500;height:450"
        CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
    </OBJECT>
    </DIV>
    
  2. Define your script language.
    <SCRIPT LANGUAGE="JScript">
    <!--
    
  3. Extract either the PixelLibrary or MeterLibrary from your control.
       m = DAControl.PixelLibrary;
    
       m = DAControl.MeterLibrary;
    

    The variable m is shorthand for the DAStatics Library. Every function and property that is in that library needs to be preceded by this variable so the interpreter knows where to find it.

  4. Write your code. When you have created the image or sound you want to display (which can be as elaborate as you like), set it to the DAViewerControl's Image property or Sound property. In this case, the Image property is set to a solid blue plane that covers the screen:
       DAControl.Image = m.SolidColorImage(m.Blue);
    

    — or —

  5. Render the image or sound with the DAViewerControl subroutine Start():
       DAControl.Start();
    
  6. Close the JScript scripting section:
    //-->
    </SCRIPT>
    

Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.