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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

switch (channel){<br />

case 0:<br />

return keys[index].x;<br />

case 1:<br />

return keys[index].y;<br />

case 2:<br />

return keys[index].rotation;<br />

case 3:<br />

return keys[index].scale;<br />

}<br />

return 0;<br />

function SetChannel(name, channel, value){<br />

switch(channel){<br />

case 0:<br />

eval(name)._x = value;<br />

break;<br />

case 1:<br />

eval(name)._y = value;<br />

break;<br />

case 2:<br />

eval(name)._rotation = value;<br />

break;<br />

case 3:<br />

eval(name)._xscale = value;<br />

eval(name)._yscale = value;<br />

break;<br />

}<br />

}<br />

Appendix B<br />

The TCB curves example<br />

Figure B.10 shows ‘Examples\AppendixB\tcbcurves.fla’ in action. In the example you can move,<br />

scale or rotate the key positions using the mouse. For each key position you can set the time,<br />

tension, continuity and bias. The crosshairs give an indication of the curve used <strong>to</strong> move around<br />

the key positions, and as you can see there is a smooth motion throughout. The crosshairs bunch<br />

up when the section duration is long and appear widely spaced when the section duration is short.<br />

The crosshairs are positioned with a call <strong>to</strong> the function ‘updateCrossHairs’. This function is called<br />

whenever the user adjusts the curve.<br />

function updateCrossHairs(){<br />

var i, name, interval, time = keys[0].millisecs;<br />

409

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

Saved successfully!

Ooh no, something went wrong!