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 8.9 How two movie clips can overlap<br />

The smaller movie clip A can be positioned in one of 10 possible places, in relation <strong>to</strong> the<br />

larger B.<br />

1 No Overlap<br />

2 Top Left<br />

3 Middle Left<br />

4 Bot<strong>to</strong>m Left<br />

5 Top Middle<br />

6 Inside<br />

7 Bot<strong>to</strong>m Middle<br />

8 Top Right<br />

9 Middle Right<br />

10 Bot<strong>to</strong>m Right<br />

If we were <strong>to</strong>tally general and allowed the case where movie clip A can be bigger than movie<br />

clip B then there would be other cases, but for now we will only consider the case where both<br />

the width and height of clip A is less than clip B.<br />

Table 8.3 gives the conditions that will identify the placement of the smaller movie clip in<br />

relation <strong>to</strong> the larger one; we use (left1, <strong>to</strong>p1, right1, bot<strong>to</strong>m1) <strong>to</strong> define the rectangle for A and<br />

(left2, <strong>to</strong>p2, right2, bot<strong>to</strong>m2) <strong>to</strong> define the rectangle for B.<br />

Apart from the special case of ‘No overlap’ it takes four tests <strong>to</strong> determine the location; we need<br />

<strong>to</strong> test for the left, <strong>to</strong>p, right and bot<strong>to</strong>m of the first movie clip in relation <strong>to</strong> the second. The<br />

location determines which of these tests we need <strong>to</strong> do. If we first check the ‘No overlap’ case<br />

and find that this does not apply then we need <strong>to</strong> identify which of the nine other cases is the<br />

112

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

Saved successfully!

Ooh no, something went wrong!