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 />

Pay particular attention <strong>to</strong> the font section. Here there are two fonts mentioned; ‘_sans’ uses just<br />

15 bytes. This is because the small text area at the bot<strong>to</strong>m of the game is a static font that is set <strong>to</strong><br />

be a device font by checking the box in the Properties panel.<br />

Figure 13.6 Using device fonts<br />

See what happens if this box is not checked.<br />

Font Name Bytes Characters<br />

----------------------- -------- -----------<br />

Arial 2125 GLRUacdeghiklmnoprstuwx<br />

Arial Narrow 1087 .0123456789OPST<br />

This includes every font outline needed <strong>to</strong> display the line ‘Get more help using static text with<br />

linked URL’. Rather than this using just 15 bytes it uses 2125 bytes, over 100 times the size, just<br />

because one simple check box was overlooked. Notice also that the font outlines included for the<br />

Arial Narrow font contain the numbers and ‘OPST’, just the outlines needed <strong>to</strong> display ‘STOP’<br />

along with the number text boxes. When you are trying <strong>to</strong> keep the game small, device fonts<br />

make a huge difference <strong>to</strong> the file size.<br />

Pong, one of our favourites<br />

Before we look at how <strong>to</strong> code the game let’s look at how the use of fonts can influence the size.<br />

You can see from the Movie Report for Pong that the game uses just 5854 bytes or around 5 K. But<br />

look where the bytes come from: 4688 of the 5854 come from the numbers in the ‘JellybabyITC’<br />

font. If you are really strapped for bandwidth you could use a device font here. As you know,<br />

device fonts use just 15 bytes so the <strong>to</strong>tal size would come down from 5854 <strong>to</strong> just 1166. See what<br />

impact fonts can make on the file size of a small game. If we had chosen <strong>to</strong> embed the entire font<br />

instead of just the numbers, then the game would have used 42 131 bytes, nearly 40 K more than<br />

we could have used for a device font. My recommendation for these small loader games is <strong>to</strong> use<br />

device fonts unless you really cannot.<br />

pong.swf Movie Report<br />

----------------------<br />

Frame # Frame Bytes Total Bytes Scene<br />

------- ----------- ----------- ----------------<br />

1 5854 5854 Scene 1 (AS 2.0 Classes Export ..<br />

192

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

Saved successfully!

Ooh no, something went wrong!