Home  >  Development  >  blogs

More Lightweight ActionScript Goodies

AddThis Social Bookmark Button

Here's fun little AcitonScript-only project that takes advantage of some of the concepts I've discussed recently. This is a great project for learning the drawing API, experimenting with Flash & math-based drawing, learning ActionScript-only projects, or seeing object caching in action. This application itself doesn't have a lot of business value, but its a great example to teach these principles so that you can use them in your own applications.

Similar to my last post on lightweight charts, this example is an ActionScript-only project that takes advantage of only the Flash player's drawing api. There are lots of great features in the Flash player that enable the rich capabilities that define RIA, and my favorite by far is the drawing API.

Here's the application running:

This text is replaced by the Flash movie ActionScriptShapes.
(Click anywhere in the black area to generate a new shape)


This example was inspired by the old Flash MX 2004 book "Flash Math Creativity", however with my own influence on there.

First, everything in this example is randomly generated. The colors are randomly selected. The shapes are randomly set from a subset of shape classes. The movement speeds and directions are randomly calculated, and functions used to determine the shape movement are randomly selected. You can click anywhere on the application, and it will clear & generate a new shape pattern.

Second, everything in this example is fully object oriented. There is a base shape class, and every shape instance inherits from that class. This is so that code is encapsulated, easy to understand, minimizes code duplication, and maximizes code reuse.

Third, it uses object caching to minimize the number of objects being created at runtime, therefore maximizing the runtime performance.

Last, its 100% ActionScript, compiled with the Flex 3 compiler. This compiled swf file in this example is a miniscule 3 K. This is actually a fraction of the size of the screenshots of the application in action that I have below (which are anywhere from 35 to 65 K each).

You can view the full application source code here:
http://www.tricedesigns.com/portfolio/actionscriptshapes/srcview

You can download the full source code here:
http://www.tricedesigns.com/portfolio/actionscriptshapes/srcview/ActionScriptShapes.zip

Using the drawing API, some math, and some creativity, you can create some really interesting shapes and you just might be surprised with what you end up with. Here are a few snapshots I was able to capture:

1.jpg

2.jpg

3.jpg

4.jpg

5.jpg

Comments

5 Comments

ras said:

now thats cool!

Nik said:

Awesome!... And very inspiring.
Thanks for providing the source code - this will be great to learn a few things from!

Adam Flater said:

Sweet.. now let's see it working with Degrafa.. ;) Seriously, cool stuff... reminds me of a something you'd see on http://levitated.net/.

M.R.Sepehr said:

WOW Very Nice.I like all ov These.Dingggg!!!!!!

neato...more stuff to digest :) Reminds me of high school, prolly way before all you cats out there. I used to code these sort of Quix styled animations in Pascal. Of course there was no mouse then to interact with them and my brain had a lot less fog to work in!

Those were the days...

peas

DK

Leave a comment


Type the characters you see in the picture above.

Tag Cloud

Related Books

Development Series

Get an overview of the tools and technologies that work together to allow developers to build Rich Internet Applications (RIAs) quickly and easily.

Anatomy of an Enterprise Flex RIA

Archives


 
 


Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.

About Us
Meet the Experts
Meet Our Contributors
Send Us Feedback