Direction | control
Today for everyone to make a keyboard with the key to control the animation, animation effect you can directly point to animation, and then press the keyboard on the arrow keys can see the effect! I hope you like it.
Click here to download the source file
1. Create a flash document of 250x190 size. Then import the prepared picture footage into the stage. Then press Ctrl+f8 to create a new component, type movie Clip, and then add a layer named: Images and script, as shown in the following illustration:
2. Then put the MC on the stage, click with the mouse, and then name an instance square:
3. Below we add action instructions to the script layer of the movie clip var speed = 5 Use a variable, click the arrow keys can move 5px, and then use This.onenterframe = function () {} to determine which key was pressed!
4. Then add the code for the identification key:
5. Set the change distance of coordinate, namely speed.
6. The final code is as follows:
7. Finally put the imported pictures into the images layer inside! This tutorial is very simple, the main to let beginners a simple understanding of ActionScript code! I hope you like it! Please continue to pay attention to this site! Thanks for reading.