Reflection in ActionScript 3

I was creating an online gallery for a project at work when came across the need for dynamically created reflections. We had an existing class that we usually used for reflections, but it was a bad port from AS2 to AS3 and I was never happy with it. It tended to be hard to work with and pretty inefficient.

In an attempt to make things better, and make my life easier in the process, I sat down and created my own Reflection class.

Here is what I came up with.

Below is a sample of the result. The moving text shows how elements fade away from the reflection point. Also, if you click and drag in the top half of the image you will see how the reflection can update dynamically.

Reflection flash demo should be here

The idea behind the class is pretty simple. Basically, you create a new Reflection object and then pass it any display object that you want to reflect. Then, whenever you tell it to ‘refresh’, it will look at the target object, copy the bottom area, flip and fade it.

It uses the bounding rectangle of the target object to figure out what to reflect, but you can also override this by specifying a rectangle area to reflect.

You can also specify a number of different things, such as how tall you want the reflection be, how often it should refresh, and how transparent it should start and finish.


If you would like to check out the code for this reflection class you can do by downloading it here: Reflection Class AS3

{lang: 'en-GB'}
Posted in ActionScript | Tagged , , , | 1 Comment

One Response to Reflection in ActionScript 3

  1. Hi Andrew

    Wow, thanks for a brilliant class. Usually I use a reflection class from, but I don’t think it’s working well with dynamic textfields. However, your class does and it’s pretty easy to use.

    A little usage information would be nice though, but I figured it out. For anyone else, this class creates a sprite that you have to add to the display list and place with X and Y coordinates. Have a look in the classfile for setting alpha and other options…

    Joel Gr√łndrup

Leave a Reply

Your email address will not be published. Required fields are marked *

× 3 = eighteen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>