Video Reflection

21

Posted by VitaminB | Posted in ActionScript, Source Downloads | Posted on 29-06-2008

Tags: , , ,

In this tutorial i will show you how to create a reflection for your video content in flash.

Okay so let’s get started.

Setup your stage as shown below.

stagesetup

1. Import Video

Import a video into the Video layer with dimensions of 320×240.Set the instance name to vid.

2. Create the reflection movieClip.

Create a new movieClip on the Reflect layer by using the rectangle tool and set the dimensions to 320×240. In the properties panel for the movieClip set the instance name to ref. Set the blend to “Overlay“. And finally tick the ” Use runtime bitmap caching” It should look like the image below.

Reflection Clip Properties

Align the movieclip right underneath the video as this will be the reflection.

3. Next we will create a gradient mask for a smooth fadeout effect.

On the Mask layer create a new movieClip with the same dimensions as the video and the reflect clips. We will create a gradient mask, so the movieclip needs to be a gradient fill from top to bottom. Set the gradient to be top 100% black and bottom 0% black. So basically it will be from top to bottom black to transparent. Settings shown below. Place the movie clip right above the reflection clip as this would be the smooth fade effect mask.

reflect gradient

In the properties panel for the masker clip set the instance name to “masker“. Set the blend mode to “Overlay” and tick the ” Use runtime bitmap caching” It should look like the image below.

mask properties

4. Finally we will code the ActionScript for the reflection.

Select the first frame of the Actions layer and open the Actions panel (F9).

Now paste the following:

import flash.display.BitmapData;

var bmd:BitmapData = new BitmapData(vid._width, vid._height);
ref.attachBitmap(bmd,1);

//Flip the the image
ref._yscale = -100;
ref._y += ref._height;

this.onEnterFrame = function(){
bmd.draw(vid);
}

//set the mask
ref.setMask(masker);

That’s it. Test your movie and it should look similar than the example below.

Video Reflection

Drop me a line if you need any help or the source for this tutorial.

Comments (21)

Thank you very much, excellent tutorial.

Great tutorial, I was expecting something much harder but the way you did it is actually much easier. Cheers mate PS: I also added this to DIGG.

Nice work, thank you for sharing this.. How can i subscribe to your RSS feed? I am a newbie to flash and find this really useful… keep on sharing please…..

Thank you so much, this very nice post

This is very very cool, thank you so much for this.

Couldn’t get it to work. coming up with this error: Scene 1, Layer ‘Actions’, Frame 1, Line 3; 1119: Access of possibly undefined propery_width through a reference with static type fl.video:FLVPlayback: var bmd:BitmapData = new BitmapData(vid._width, vid._height); and i also get the same error message but with the property_height. Can you help please???!!

i used actionscript 2.0 and the movie plays but the reflection doesn’t work. Any ideas???

Did you click the runtime bitmap cache?

Having the same problem as Curtis…runtime bitmap cache is clicked but no reflection.

is this an actionscript2 solution? I am using CS4 and AC3… this reflection trick has been really hard for me to find because all the solutions have been in AC2…

anyone figure this out?

I also can’t get the reflection working… and the bitmap cache is checked. Any ideas?

My doubt… It works with the streaming object too?

Or only in a embed video in the movie.

Thanks.

I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

Tried this but I couldn’t get the reflection to work either. Could you guys post a demo or sample?

Got this to work! thanks for the tutorial! quick and easy!

could you please post the source for this tutorial…?

thank you very much

Hi there, will put the source up as soon as I get a chance. I will also post an AS3 version.

Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

Cheers Sandra, glad you like it..

Ha, once again, great stuff… I added this to the youtube player and it works like a charm

Magic… Thanks again !

I can not get the reflection to work. Can you post the .fla?

Write a comment

Get Adobe Flash playerPlugin by wpburn.com wordpress themes