Articles Tagged "ActionScript"

Hexadecimal Color Fading Array

A while ago I wrote a Hexadecimal Color Fading Tutorial explaining how to select a single color at any point on a gradient between two specified colors. In that tutorial there was a function which efficiently broke each of the 2 specified colors into their Red, Green and Blue components and then calculated a single new color at a specified point between them.

Here's what the code looks like: ...
Read More

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

Flash Rotation Bug (with Fix)

I recently ran into a nasty “little” bug in Flash that happened to eat up a “big” chunk of my time. I’m surprised I haven’t heard more about this particular bug since the conditions which cause it would seem fairly common.

Let’s say you’re using an onEnterFrame event to count frames as they pass with code like this:

//
//
var count = 0;
onEnterFrame = function(){
    count++;
}
//
//

Now let’s suppose we want to rotate an arrow 1 degree every time a frame passes. We could write code like the following:
Read More

Flash CurveTo Visualization Code

If you’ve ever wondered how Adobe Flash draws a curve when issued a “curveTo” command this article will help you visualize the process.

As you probably know, Flash requires three points to draw an exponential curve.

  1. A Starting Point. Wherever the Flash drawing pen is currently located. If you have not previously moved the pen with “lineTo”, “curveTo”, or “moveTo” the pen defaults to the origin (0, 0).
  2. A Control Point. A point which the the Flash drawing pen will head toward before changing direction and heading toward the end point. The pen generally does not go through the control point unless your “curve” is nearly straight.
  3. An End Point. Where the Flash drawing pen will come to rest when the curve is complete.

But how exactly does the control point “control” the shape of the curve? How does Flash precisely map the vague concept of heading towards a point and then land precisely at another point? Take a look at the SWF file below
Read More

Other People’s Classes

I was searching for a quick way to preload multiple files but wasn’t having much luck until I found a great page listing various preloading classes that simplify most common content loading tasks. Out of all the preloading classes listed on the site, I chose GreenSock‘s Preload Asset Manager class because
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

Classes and Operators

I’m certainly no expert when it comes to writing Flash classes, but here’s my question. Can you use operators on class members? I did a quick search on the web and only found information for C++ where it’s called “overloading operators” but I didn’t find anything about it in ActionScript. In case you’re curious why I’d like to use operators on a class, here’s what I was thinking…
Read More

© Sean O'Shell 2007-2024