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.

Chapter 24: Embedding <strong>Flash</strong><br />

can be any string that is useful for the context. To respond <strong>to</strong> all fscommand events we need <strong>to</strong><br />

add a member function <strong>to</strong> the main window of our wrapper.<br />

void C<strong>Flash</strong>TalkDlg::OnFSCommand<strong>Flash</strong>(LPCTSTR command, LPCTSTR args)<br />

{<br />

if (_stricmp(command, "click")==0){<br />

AfxMessageBox("<strong>Flash</strong> passed click fscommand");<br />

}<br />

}<br />

You test for the command string using the function ‘strcmp’ for a case-sensitive comparison or<br />

‘_stricmp’ if you want it <strong>to</strong> be case insensitive. If the strings are the same then the string comparison<br />

function is set <strong>to</strong> zero. In this way you can send any message from <strong>Flash</strong>. Having sent a message<br />

your wrapper may want <strong>to</strong> query the current state of variables in <strong>Flash</strong>.<br />

If you need <strong>to</strong> get the value of a variable in <strong>Flash</strong> then use:<br />

m_flash.getVariable(variablename)<br />

Regardless of the type of the variable this function returns a string.<br />

If you want <strong>to</strong> set a variable in <strong>Flash</strong> then use:<br />

m_flash.setVariable(variablename, variablevalue)<br />

where both ‘variablename’ and ‘variablevalue’ are both passed as strings.<br />

You will be able <strong>to</strong> see from the list of exposed methods in the <strong>Flash</strong> ActiveX control that<br />

there are a considerable number of other ways that you can communicate between the wrapper<br />

and <strong>Flash</strong>. The wrapper can control the playback by setting the frame and the play mode for both<br />

the main timeline and any Movie Clips, but the principal methods you will use are ‘setMovie’,<br />

‘setVariable’, ‘getVariable’ and the event callback ‘OnFSCommand’.<br />

Embedding <strong>Flash</strong> on a PocketPC 2003<br />

The 2003 version of PocketPC software brought some changes <strong>to</strong> the platform. To embed<br />

<strong>Flash</strong> you will need <strong>to</strong> create an HTML View window and then populate this with an<br />

HTML file that accesses your <strong>Flash</strong> file. It is perfectly possible <strong>to</strong> embed both the HTML<br />

file and the <strong>Flash</strong> file so you can create a single executable that will appear <strong>to</strong> the user <strong>to</strong><br />

be a self-contained executable. To do this you will need a copy of Embedded Visual C++<br />

4, which is freely available from Microsoft. The URL at the time of writing is http://msdn.<br />

microsoft.com/vstudio/device/embedded/download.aspx. After installing you should install any<br />

service packs and finally install the SDK for PocketPC 2003. Having successfully installed<br />

all the development <strong>to</strong>ols you should be able <strong>to</strong> compile and execute on your PocketPC<br />

the program ‘HTMLHost.exe’; the project file for this is found on the CD at ‘Examples/<br />

Chapter24/PocketPC/ppcflash.vcw’. This code is just a slightly amended version of the<br />

‘HTMLHost’ sample that comes with the PocketPC 2003 SDK. The default installation puts<br />

385

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

Saved successfully!

Ooh no, something went wrong!