Articles Tagged "SWFs"

Box Bender

Here’s something to vacantly stare at while pretending to work.

Clicking will cycle through dark, bright and all colors.

How to Swing a Pendulum Arc

In my previous article explaining How to Draw an Arc with ActionScript a few readers asked how to simulate the swing of a pendulum or the swaying motion of a falling leaf. Hopefully this tutorial will add a little insight into that process. The technique I’ll be using won’t mimic the effects of gravity but will be more similar to the metered swing of a clock’s pendulum or a large carnival ride.

Observations
: Before we start writing any code, let’s make a few general observations. If you were to swing a pendulum from right to left, you could note the following:

  1. Once the pendulum is dropped or released, it begins to pick up speed as it approaches the bottom of its arc. This gradual acceleration is similar to “Easing In”.
  2. Once the pendulum passes the bottom of its arc, it begins to swing upward and consequently slows down which is similar to “Easing Out”.
  3. Once the pendulum reaches the top of its arc on the left, it begins to swing backwards from left to right. The swing from left to right is a mirror image of the previous swing from right to left.

Conventions: With those observations in mind we can start
Read More

Combining Shapes from the Past

When writing my recent article about Combining Vectors in Flash the Overlapping Circles example reminded me of the entries I made for the now legendary Bit-101 “25 Lines Contest” back in 2002. I tried looking for all of the old contest entries but they seem to have been erased from the web.

Fortunately I found a few different versions of the entries I posted back in 2002 still loitering on my hard drive in an abandoned folder thought to be lost long ago. So without much further ado, here are two files that probably haven’t been seen by anyone in the last five years!
Read More

Combining Vectors with Flash

Flash has always managed to draw vector shapes very quickly and when all things are considered, you have to admit that it can handle quite a few shapes before puking and bringing things to a crashing halt. But not too many people take advantage of that fact so I’d like to show an example of what you can do with Flash if you never “lift your pen” or if you don’t issue an “endFill” or “beginFill” command while drawing various shapes. To get a better idea of what I’m talking about, try clicking and dragging in the SWF below (pressing any key clears the screen):

...
Read More

Draw an Arc with ActionScript

Drawing an arc (a segment of a circle’s circumference) is very similar to drawing a complete circle. Just like drawing a circle, drawing an arc requires you to specify the center, the radius, and the number of steps to take from the first point to the last. But drawing an arc also requires additional information such as the angle of the first point on the arc, the direction (clockwise or counter-clockwise) to travel around the circle’s circumference, and the angle of the last point on the arc.
Read More

Basic Circle Drawing ActionScript

Do you know how to draw a circle with ActionScript code? It’s a handy thing to know. You can use it to draw pie charts, equilateral polygons, analog clock faces… you can even use it to script motion. If you use Flash for any type of drawing purposes, knowing the math behind the circles (trigonometry) can be very helpful. In the simplest of terms, drawing a circle can be as easy as counting from 0 to 1.
Read More

ActionScript Easing Functions

Unlike most other easing equations or functions, my easing functions are 0 to 1 based (like the “Math.random” function). This makes it easier to isolate the concept of “easing” from the concept of “tweening”. Tweening is responsible for creating a series of equidistant values between an initial state and a final state. Easing is responsible for shifting those values so they are no longer equally spaced.

There are times when you may want to weight a single random value to favor one number over another. For example, you may want a random number between 0 and 100 but you would prefer a number closer to 0 than to 100. In this situation, there is no need for a “tween” as you are only generating one number and there is nothing to go be”tween”. This is where easing functions which have been isolated from their tweening counterparts can come in handy.

Here are my most frequently used easing functions:
Read More

© Sean O'Shell 2007-2024