1. Code
  2. ActionScript

Quick Tip: Easy Shape Creation with UniqueShape


In this Quick Tip, I'll introduce you to a library called UniqueShape that will help you create common shapes using ActionScript 3.

Final Result Preview

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

Each of these vector shapes was created with a simple snippet of ActionScript, like so:

Step 1: Brief Overview

Using a third-party class called UniqueShape, we will create different kinds of common shapes. You can download the source of the class from the developer's site.

Step 2: Set Up Your Flash File

Launch Flash and create a new Flash Document; set the stage size to 470x300px and the frame rate to 24fps.

Flash common vector symbols and shapes

Step 3: ActionScript

The shapes are created using 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.

As you can see, the creation is pretty easy, an instance is created using the SingleShape class and the class corresponding to the actual shape, and then it's simply added to the stage like any display object.

Take a look in the \whirlpower\uniqueshape\items\primitive\ folder to see what other shapes are available.

Step 4: Document Class

Add the class name to the Class field in the Publish section of the Properties panel to associate the FLA with the Main document class.

Flash common vector symbols and shapes


That's it! Experiment using this class and have fun with the 18 shapes included!

I hope you liked this Quick Tip, thank you for reading!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.