Forum: Log-In | Register | Contact | Shop


SwishMax Tutorials And Resources
Where Imagination Is The Creation

 


Add


Welcome To Swish-Designs.co.uk Have a Nice Friday

Display A Keypress - Swishmax

Learn how to display the character of the key you pressed on screen using swishmax.




Instructions

Click on the movie above to set the focus, and then press any key on your keyboard to display that character on screen.




First Of All

You will need the latest build of swishmax installed on you system to do the following tutorial.
for the sake of this tutorial i have used a movie size of 190 x 170 pixels with a frame rate of 25fps.
on a white background.


Step.1

Using the text tool and set as dynamic text i created a box with a font size of 96 and centered text and black in colour #000000, name this pressed.



Step.2

now create another dynamic text box using a font size of 14 and colour of black #000000 and name it info, place it underneath the pressed text box, you should have something looking like fig.1 below.
Fig.1



Step.3

Now on Scene_1 add the following code.

Code:
onEnterFrame() {
/*Code by Craig Lowe
http://www.swish-designs.co.uk
09:30 01-09-07*/
ascii = Key.getAscii();
pressed = String.fromCharCode(ascii);
if(pressed==""){
info="Press A Key To Display It";
}else{
info="you pressed "+pressed;
}
}
onLoad() {
stage.showMenu = false;
}