1. Code
  2. Mobile Development

Quick Tip: Simulate an Android Lock Screen with ActionScript

Scroll to top
Read Time: 3 mins

The Lock Screen is a part of an operating system, mostly used in mobile devices, that prevents accidental input. This Quick Tip will show you how to simulate an Android Lock Screen with ActionScript. Let's get going!

Final Result Preview

Let's take a look at the final result we will be working towards:

This is a very simple version of the Android pattern-lock screen. Drag your mouse along the dots in the path indicated by the semi-transparent white lines in order to "unlock" the SWF. Naturally, the white lines are only there for demonstration purposes!

Step 1: Brief Overview

We'll make use of Mouse Events and Arrays to store and compare the user input and the correct pattern. A new Screen will be shown when the correct pattern is entered.

Step 2: Set Up Your Flash File

Launch Flash and create a new Flash Document, set the stage size to 320x480px and the frame rate to 24fps.

Step 3: Interface

This is the interface we'll be using, the white dots in the image are MovieClips named from left to right one, two, three... and so on. Semi-transparent white lines are used to indicate the correct password (you may want to remove this for real usage).

Step 4: ActionScript

Create a new ActionScript Class (Cmd+N), save the file as and write the following lines, please read the comments in the code to fully understand the class behavior.

Change the values in the pass array in order to change the unlocking pattern.

Step 5: Document Class

Remember to add the class name to the Class field in the Publish section of the Properties panel.


You've created a useful Lock Screen for your applications or even a website. You can adapt the project to meet your needs or use this technique to build your custom LockScreen. How about using the graphics object of a Sprite to draw lines that follow your mouse's path?

I hope you liked this tutorial, thank you for reading!

Editor's Note: Can't get enough of Android? Check out the latest Envato™ site:!
Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.