02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Flash</strong> <strong>MX</strong> <strong>2004</strong> <strong>Games</strong><br />

Figure B.6 Using Excel <strong>to</strong> chart exponential curves<br />

The tweening example project<br />

In addition <strong>to</strong> the Excel spreadsheets of the curves, there is the <strong>Flash</strong> project ‘Examples\<br />

AppendixB\tweening.fla’ <strong>to</strong> help you <strong>to</strong> understand how this stuff works and what the results<br />

look like.<br />

The tweening project consists of a screen that contains two check boxes <strong>to</strong> select easing in and<br />

easing out, and four radio but<strong>to</strong>ns <strong>to</strong> choose the curve type. If you deselect both the ease-in and<br />

-out options then you will get a linear interpolation. The aim of the application is <strong>to</strong> allow you <strong>to</strong><br />

click anywhere in the white area and then the yellow dot will move from its current location <strong>to</strong><br />

the new location in one second, leaving behind a trail that gives an indication of how the speed<br />

of the motion accelerates and decelerates over time. Try running the application now and you<br />

will get a feel for the different curves involved. The code inside the project uses the code snippets<br />

already outlined and introduces a point class. As you know from Chapter 10, keeping data and the<br />

manipulation of data <strong>to</strong>gether is a very useful technique; it makes your code more robust and easier<br />

<strong>to</strong> modify and is highly recommended. To create a new point, simply use the ‘new’ keyword.<br />

The function ‘point’ assigns values <strong>to</strong> the data and sets up pointers <strong>to</strong> function calls. Then <strong>to</strong> set<br />

a point you can use the method ‘set’ and <strong>to</strong> add and subtract you can use the methods ‘add’ and<br />

‘sub’. The results of the code snippet here would be <strong>to</strong> set ‘offset’ <strong>to</strong> the point (2, −18).<br />

402

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!