****NOTE**** In order to use this class properly, your movieClip elements (that is, it's internal elements) must be placed beginning at the POINT OF ORIGIN inside the movie clip. That is, your elements must not be situated in the negative.

Okay, down to it. Before getting started as always if you so choose, you can watch a video tutorial I've made on my website for this particular item as well as other topics at http://www.ascensionsystems.ca/tutorials/ and also if you want to stay informed as to when I'll be releasing new tutorials both on Actionscript.org and the corresponding video on my site, go to that page and drop your email address in the subscribe box(top left corner).

Now for the class. The first thing you need to do is download the class and set it up for use. To get the file you need, go to http://code.google.com/p/ascensionsystems/downloads/list and download the file "reflect V.2.0.zip" If you don't know how to use custom classes, then search on this site for a tutorial I'm sure you'll find a great number excellent tutorials. Once you have the class set up in it's respective directory, import it.

import ascensionsytems.mirror.reflect


Now the rest of this is very simply. Either load in movie clip from the library like so...

var myLibraryMovie:movieInLibrary = new movieInLibrary();
addChild(myLibraryMovie);


Or you can just work with something you've already dragged onto the stage. If this is what you've done, give the movie an instance name of "myLibraryMovie" (or whatever suits you, just adjust the name in this tutorial accordingly).

Now you need to create a new instance of the reflect class. Do so like this:

var myReflection:reflect = new reflect();


Once you've created the new reflection, the key to it all is accessing the public functions that are inside the class. The first of the two functions is to create the reflection. This function requires 5 parameters. Don't worry it's not that complicated. It works like so..

myReflection.constructReflection([first param], [second param], [third param], [fourth param], [fifth param]);


The first param is the name of the movie clip you want to reflect.
The second param is the alpha or opacity level of the reflection. So, us 0.0 to 1.0 for 0-100% opacity (cause it's as3).
The third param is the starting threshold of the reflection opacity. This would normally be set to 0, but play with it to see what your preference is.
The fourth param is the ending threshold of the reflection opacity. (Because the opacity is set by a gradient mask) Set this typically to the height of the reflected movie clip.
And last, the fifth parameter is the offset. So, as mentioned in the introduction, if you want to have the reflection be distanced from the reflected movie like in the cloud example, or if you want it closer to the clip, you can enter a negative or positive number in this field.

Okay so now that I've explained that all, lets see what this code would actually look like:

myReflection.constructReflection(myLibraryMovie, .5, 0, 250, 0);


And there you have it. You now have a dynamic reflection.

If you want to add something to the movie your reflecting or put a text field in it like in the cloud example, you're going to want to be able to update that reflection. To do this, simply call a function named "refresh" on the reflection class you want to update, like so:

myReflectionClass.refresh();


So there you have it. Enjoy!

P.S. You can message me on Actionscript.org or you can go to http://www.ascensionsystems.ca/tutorials/contact.html either with questions about this tutorial or to request a tutorial. In either case, I will bring your requested tutorial or question back to Actionscript.org in a post. :)