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 12.4 Communication between <strong>Flash</strong> and the HTML page using fscommand<br />

The variable ‘str’ is the input box that you can see in Figure 11.4 displaying the string ‘<strong>Flash</strong> calling’.<br />

When ‘fscommand’ is called for Internet Explorer, if the HTML page contains a VBScript Sub<br />

‘xxxx_FSCommand(cmd, args)’ where ‘xxxx’ is the ID used for the <strong>Flash</strong> object, then this subroutine<br />

is called. When fscommand is called for Netscape, if the HTML page contains a JavaScript<br />

function ‘xxxx_DoFSCommand(cmd, args)’ where ‘xxxx’ is the name used for a <strong>Flash</strong> embed, then<br />

this function is called. A VBScript can call a JavaScript function on the same page using the form<br />

‘call functionname(parameter1, …)’. In the example the VBScript function ‘flash_FSCommand’<br />

calls the JavaScript function ‘flash_DoFSCommand’ using the ‘call’ method.<br />

In this instance <strong>Flash</strong> affects the actual page by setting the document object with the ID ‘flashStr’,<br />

which is the SPAN of the one item table, <strong>to</strong> the value passed in the variable ‘args’.<br />

180<br />

...<br />

<br />

function flash_DoFSCommand(command, args){<br />

if (command == "setSpan"){<br />

document.all.flashStr.innerHTML = args;<br />

}<br />

}<br />

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

Saved successfully!

Ooh no, something went wrong!