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

96<br />

97 MSG msg;<br />

98 while (GetMessage(&msg, NULL, 0, 0))<br />

99 {<br />

100 TranslateMessage(&msg);<br />

101 DispatchMessage(&msg);<br />

102 }<br />

103<br />

104<br />

}<br />

105<br />

106 }<br />

return 0;<br />

Listing 24.3<br />

In common with any Windows application it starts by registering the class in line 50; this in<br />

turn calls the function listed between lines 11 and 34. Then in line 52 we create the main window<br />

for this program and size it <strong>to</strong> 240 by 280 pixels. Then in line 65 we use the new Shell function<br />

‘SHFullScreen’ <strong>to</strong> declare this as a full screen application that hides both the task bar and any<br />

but<strong>to</strong>ns. This allows us <strong>to</strong> move the window, which is accomplished in line 67. The app size is<br />

now greater. In line 74 we call ‘InitHTMLControl’ which is declared in the ‘htmlctrl.h’ header file<br />

and is found in the ‘htmlview.lib’ so please ensure that this library is added <strong>to</strong> your project. Then<br />

we create the HTMLView in line 76. Note in this instance that the positioning of the control is<br />

inset. Changing these parameters allows you <strong>to</strong> bleed off your <strong>Flash</strong> entirely. Also removing the<br />

WS_BORDER, window style will remove the box surrounding <strong>Flash</strong> in the example. Finally,<br />

in lines 93 <strong>to</strong> 103 we set the HTML file <strong>to</strong> load. By using the embedded resource ideas set out<br />

earlier you could save this in a resource and then load it out <strong>to</strong> a temporary file along with the<br />

<strong>Flash</strong> swf so that the entire exe is self-contained. To use the HTMLView you use ‘SendMessage’.<br />

Space is limited so if you intend <strong>to</strong> use a more sophisticated application then I suggest reading<br />

the documentation that comes with Embedded Visual C++ 4. In the sample you can see how<br />

communication between <strong>Flash</strong> and the host is achieved.<br />

Summary<br />

If you have ever done any Windows programming then much of the information in this chapter<br />

will be familiar and you may be pleasantly surprised how easy it is <strong>to</strong> incorporate <strong>Flash</strong> in<strong>to</strong> your<br />

application. If you have never done any Windows programming then the whole lot probably<br />

seems <strong>to</strong>tally confusing. You can actually use the source code without understanding it, if you<br />

wish, but if you do intend <strong>to</strong> create a wrapper for a <strong>Flash</strong> movie then I recommend getting <strong>to</strong><br />

grips with at least the basics of Windows programming.<br />

Using the <strong>Flash</strong> ActiveX control in this way allows you as a developer <strong>to</strong> create desk<strong>to</strong>p characters,<br />

email virals and screensavers. It is certainly worth looking in<strong>to</strong> how the control can be used<br />

<strong>to</strong> extend your applications.<br />

388

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

Saved successfully!

Ooh no, something went wrong!