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 Main.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


Conclusion

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!

Tags:

Comments

Related Articles