Easy to use, Dynamic Reflection Class for AS3

How to use the class.
Jesse Nicholson
I'm a flash developer in Ontario Canada, I run my own business and I love pushing the limits of flash and exploring the latest developments from Adobe. I have developed a way to author flash 10 in the flash CS3 IDE and would like to begin posting articles on working with the new features (specifically 3d).
View all articles by Jesse NicholsonOkay, 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. :)
Spread The Word
7 Responses to "Easy to use, Dynamic Reflection Class for AS3" 
|
said this on 27 Apr 2009 8:23:02 AM CST
Hi) Thanks for really fas
I fnxBMD.fillR not fnxBMD.fillRect sind last byte is for a i had some nasty r |
|
said this on 27 Apr 2009 10:50:21 AM CST
Thanks Valentine for the
|
|
said this on 20 May 2009 10:35:07 AM CST
Great bit of script! Work
Just one th Thank you ve |
|
said this on 23 Jun 2009 4:32:17 AM CST
Good Article,
But i st |
|
said this on 23 Jun 2009 5:29:31 AM CST
Thank UUUUUUUUUUU.......V
Now i hav |
|
said this on 26 Sep 2009 10:25:13 AM CST
The only issue I seem to
|


Author/Admin)