07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ADOBE DIRECTOR BASICS<br />

3D: Controlling action<br />

Characters, key and keyCode<br />

On Macintosh, the value of _key.keyCode depends on the actual physical key that the user presses. On an English<br />

keyboard, the key beside Caps Lock is an A; on French keyboard it is a Q. In both cases, the value of _key.keyCode<br />

produced by pressing this key will be 0.<br />

This means that, on Macintosh, you can use _key.keyCode to indicate exactly which physical key the user pressed.<br />

On Windows, the value of _key.keyCode depends on the character that is generated when the key is pressed. Pressing<br />

A on an English keyboard or A on a French keyboard will lead to the same value of _key.keyCode, even though<br />

different physical keys are pressed.<br />

Pressing the key beside the Cap Locks key produces Q in French, and a _key.keyCode of 12<br />

Issues with keyPressed() on Macintosh<br />

In <strong>Director</strong> 11.5, on Macintosh, the values of _key.key and _key.keyCode immediately after a #keyDown event<br />

represent the character that was typed and the key that was pressed respectively. However, keyPressed(aChar)<br />

assumes that the user is typing on a standard US keyboard. Here is a simple Movie Script handler that you can use to<br />

check this:<br />

on keyDown()<br />

if not _key.keyPressed(_key.key) then<br />

put "KeyPressed("&QUOTE&_key.key&QUOTE&") error"<br />

end if<br />

if not _key.keyPressed(_key.keyCode) then<br />

put "KeyPressed("&_key.keyCode&") error"<br />

end if<br />

end keyDown<br />

Set the input keyboard layout for your computer to something other than a standard US English keyboard, launch your<br />

movie and press each key in turn. Watch the output in the Message window.<br />

If you chose a French keyboard, for example, where the same Roman letters have a different layout, you will find that<br />

the keyPressed() function fails when it's used on characters that are not in the same place as on a US keyboard.<br />

Last updated 8/26/2011<br />

257

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

Saved successfully!

Ooh no, something went wrong!