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.

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

Figure A.1 Developing the boxes interface<br />

If you place a ‘put’ in the code you will see that each time that <strong>Flash</strong> sends a<br />

‘getURL(“event:myeventName”)’, Direc<strong>to</strong>r catches the event within the function. ‘put’ is the<br />

Direc<strong>to</strong>r equivalent <strong>to</strong> ‘trace’. In the current example the function ‘addBox’ is used <strong>to</strong> create a<br />

new box and initiate the physical behaviour; ‘removeBox’ is used <strong>to</strong> delete the last box that has<br />

been added.<br />

The movie can be published suitable for the Internet by setting the appropriate values in the<br />

Publish Settings dialog box. Direc<strong>to</strong>r creates a compressed file with a ‘dcr’ extension. This file<br />

contains the <strong>Flash</strong> interface; you do not need <strong>to</strong> have a version of the swf file available on the site.<br />

Sometimes you will want <strong>to</strong> pass on the ‘event’ <strong>to</strong> the 3D world. Direc<strong>to</strong>r uses the same layereddesign<br />

as <strong>Flash</strong> and in the next example, ‘Examples\AppendixA\road.dir’, you will find that the<br />

3D world is on layer 2. In this example the arrows are <strong>Flash</strong> but<strong>to</strong>ns, each but<strong>to</strong>n sending a different<br />

event <strong>to</strong> Direc<strong>to</strong>r. In addition, Direc<strong>to</strong>r sets two variables in <strong>Flash</strong> that display the current position<br />

and orientation. Each event is handled in the same way:<br />

390<br />

on turnleft<br />

sendsprite(2, #turnleft)<br />

end

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

Saved successfully!

Ooh no, something went wrong!