Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Time for action—create a chain of Fx.Tween methods


Let's see how to create a chain of Fx.Tween methods by carrying out the following steps:

  1. Create a new HTML document like we always do. It should have the following code:

    <html>
    <head>
    <script type="text/javascript" src="mootools-1.2.1-core-nc.js">
    </script>
    <script type="text/javascript">
    window.addEvent('domready', function()
    {
    });
    </script>
    </head>
    <body>
    <div id="box" style="background-color: #00f; height:50px; width:50px;">&nbsp;</div>
    </body>
    </html>
    
  2. Create a new object called boxAnimation, an instance of the Fx.Tween class, and giving it the target of our box element, which has an id of box, using the following code in our domready event handler:

    var boxAnimation = new Fx.Tween( $('box') );
    
  3. Now that we have our boxAnimation object, let's apply the first method (moving it to the right by adjusting the left margin) by entering this line of code:

    boxAnimation.start...