You are viewing the archives of the original Pixelfumes blog. This blog is no longer maintained. All of the content available on this site is available on the new Pixelfumes blog in addition to all of our new posts! Visit: http://blog.pixelfumes.com.

« Home | Adobe Kuler Widget Released » | New Adobe CS3 Box Art Revealed » | Underwater Warping Textfields » | Writing Flash for the Nintendo Wii » | Interactive Singing Holiday Card » | DHTML Snowstorm » | Apple iPhone - Runs Safari / OS X » | Adobe CS3 Icons - Interactive Display » | Roxik Pictaps - Draw a Character and Watch It Danc... » | Flash 8 Censor Blocks Area Class with Source » 

Friday, March 30, 2007 

Reflection Class V3 with Source

I was prompted today to update my Reflection Class. Many of you have posted updates and revisions of the class and I thank you all for that. I took some of the revisions and officially updated the class. The new class now supports clips that change their position. The old code would not allow an object to change the x position. This is now handled by telling the class how large of an area of a given clip should be monitored and reflected. View the demo below:


You can try the new class out below using the sliders to update the properties assigned. Once you have a look you like you can copy the code below for reference when using the class.



You can download the source and demos here.

Thanks to Mim, Jasper, Jason and anyone else who has been using/modifying the code!

Very cool. I look forward to using this in the future. Thank you!

Same here, thanks man!

This is really cool! Was wondering if it would work with any Movie Clip or does it have to be a video? A sample code would be nice if it can be done.

Howard - the code can be used with any movie clip. Just download the .as file, create a new FLA file co-located to the .as file (same directory) and paste this code into an empty frame:

import com.pixelfumes.Reflect;
new Reflect({mc:video_mc, alpha:85, ratio:255, distance:1, updateTime:0.33, reflectionAlpha:90, reflectionDropoff:7});

this assumes you have an instance name of video_mc on your movie clip - if it is different swap that out for the instance name on your movie clip.

Hope this helps!
-Sarge

I'm trying to use this class but it doesn't work in my own code, why?

[code]

this.createEmptyMovieClip("logo_mc", 999);
loadMovie("FotoShow.swf",movie_mc);

import Reflect;
r1 = new Reflect({mc:movie_mc, alpha:85, ratio:255, distance:1, updateTime:.33, reflectionAlpha:90, reflectionDropoff:1});
r1.setBounds(549,399);

[/code]

I get no errors, but i can't see the reflection...

.:FiDo:.

Fido, my guess is that the reflection is processing before the clip is loaded that you are loading with the loadMovie call. Preload that clip and ensure it is 100% loaded, once that is true, then apply the Reflect. Send me an FLA if you still have problems. Thanks.
-Sarge

Hi, thanks for the class, very cool. The class works when symbols are contained in the flash, but when you use createEmptyMovieClip fails.

I ve been trying to use it with this code and have been unsuccessful:

import com.pixelfumes.Reflect;
var container:MovieClip = _root.createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("logo.jpg", container);

function onLoadComplete(mc:MovieClip) {
new Reflect({mc:mc, alpha:85, ratio:255, distance:1, updateTime:0.33, reflectionAlpha:90, reflectionDropoff:4});
trace("onLoadComplete: " + mc);
}

If u have the solution it would be great.

Thanks,

Tomas

Thanks for the cool code! Your recent AS makes it so easy to use however I have problem getting it to work with a FLV set to widescreen 16:9. When I set the the FLV component's path to import to my widescreen FLV ( 400x225 ) the reflection doesnt match the widescreen is reflects a normal screen.

Tomas,
The class does support "createEmptyMovieClip". The problem is the movieclipLoader onComplete event. It fires before the first frame is executed so you are reflecting a blank clip. Use onLoadInit instead. The following code worked fine for me:

import com.pixelfumes.Reflect;
var loadListener:Object = new Object();

loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
r = new Reflect({mc:target_mc, alpha:85, ratio:255, distance:1, updateTime:0.33, reflectionAlpha:90, reflectionDropoff:4});
}

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip("logo.jpg", mc);

Hope that helps!
-Sarge

Eugene,
Sounds like the reflection is firing before the FLV component has updated its size. I always wait until the video is completely loaded in my FLV e.g.:

//don' apply effect to video until it is loaded
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.stateChange = function(eventObject:Object):Void {
if(video_mc.video.state == "stopped" && !r1){
r1 = new Reflect({mc:video_mc, alpha:85, ratio:255, distance:1, updateTime:.33, reflectionAlpha:90, reflectionDropoff:7});
update();
}
}
video_mc.video.addEventListener("stateChange", listenerObject);


If this doesn't help feel free to email me the FLA and I will take a look. Thanks!
-Sarge

Why is it when I scroll the page, the flash player freaks out,stutters and stops? It does this for youtube and soapbox as well. But not for stage6 or wmp based services. Could that be fixed?

Very nice to see you made an update including my adjustments. End offcourse all the others, looks very smooth now. Final version ;)

I got one more idea. to mask the reflection, but that's a personal project and maby an option for later on.

Good work guys!

Downloading gonna check it out.... thanks

Ranjeet naidu
flash developer london

this is great! but i'm having a problem with the reflection not showing up until either the entire movie plays or i drag the time slider to the end of the time bar......

Is there any way to ALWAYS keep the reflection on? Here's my code

import com.pixelfumes.Reflect;

//don' apply effect to video until it is loaded
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.stateChange = function(eventObject:Object):Void {
if(video_mc.video.state == "stopped" && !r1){
r1 = new Reflect({mc:video_mc, alpha:50, ratio:255, distance:0, updateTime:.33, reflectionAlpha:64, reflectionDropoff:3});
update();
}
}
video_mc.video.addEventListener("stateChange", listenerObject);

Thanks!
Jim

Cool thanks. Saved my brain time...hehe

brillant - now just need to port it to AS3 ;)

Nice one indeed! Just make sure you don't have any filters in the MC you are reflecting. Processor gobble!

Is there anyway that you can setBounds for a certain height at the bottom of the movieclip to be reflected, rather than the top? Using a largish video gets sluggish when you setBounds for the whole video movieClip. If you could define only the bottom 70 or so to reflect then I would assume this would enable better performance.

This Code is still ActionScript 2.0 right ?
Is it possible to change it to 3.0 ?
It does not really work with 3.0
Thanks

There is an old AS3 version here:
http://pixelfumes.blogspot.com/2006/06/actionscript-3-reflection-class-source.html

The new AS3 version is complete and will be posted within the next few weeks through Adobe.com hopefully.

Thanks!

Problem: I have absolutely no idea about flash. I have my viewer.swf script for my gallery (from airtightinteractive.com) and want to import the swf into a new swf, in witch I will put the reflection under the viewer.sfw. Undestood? :)

I tried to handle all the loadMovie and stuff, but still nothing is working, becouse I don't know how to use holders, mc's etc...
I think it should be veryvery easy for someone with just a little knowledge. :)

Can u help me please?

Thanks a lot

bboo

hi.
your class is very nice. but I have a quesitons about it.

when I reflect a movieclip button, the reflected movieclip can click too, How can I disable the reflected movieclip buttn.Thanks.

The best way to do what you are trying to achieve is to create a nested clip or button within the movieclip that you are reflecting and use it to handle the click event vs. using the entire clip you are reflecting to do so. You can also modify the class if you desire to make it do whatever you like! :)

Hi, Ben Pritchard

We are developing an dynamic animated image gallery with xml using Flash

8 & AS2, for which the images are called up from a different domain. I

have used the reflection class to achieve reflections. This works fine

when the images are called from the same domain. But, when the images are

called from another domain, the reflection class does not work. Although

the images are showing up. Please review the link provided. You will see

2 images that have the reflection working, these images are called from

the local domain. The other images are have a cross domain link. I also

need to mention that even on the local domain the refection functionality

is irratic.
The same file works correctly in the flash application environment, even

for the cross domain images, but when it is published in html page, it

malfunctions.

The link to view the animation please go to : www.isisdemos.com/carousel
I have uploaded all the project files for your review :

www.isisdemos.com/carousel/carousel.zip

I would really grateful if you could take the time and review this

problem, as I have been trying this for the last few days with little

success.

Thank you in advance.

Avijit Dutta

Avijit,
Have you tried not applying the class to the clip until after the external image has loaded? Either that or apply an update time to the clip.
-Ben

Hi and thanks for your class is soo cool ;)
i need help because using the reflect class i got this error message: ArgumentError: Error #2015: BitmapData not valid.
why?
thx

Hi and thanks for the class.
i need help because using this class i got this error message: ArgumentError: Error #2015: BitmapData not valid.
why? thx

just wanted to say very cool Class/project and thank you for sharing.

Cheers,
Steve

hi sarge i'm Luca, you redirect me here from the old reflect class post :)
this new version is really cool, now supports the alpha chan of png and gif images...great! thanks a lot!
i've a question for you:
is possible to cover a reflection of one item with another one?
I found very difficult the solving of this problem: here you can find a very simple example of what i'm talkin about...
http://img134.imageshack.us/img134/6674/examplepc5.jpg
one mc and another one, on two different layers. the reflection of the mc behind pass through the other :(
as always thanks a lot for everything.
bye!

something very weird going on for me I just get a reflection of the top right quarter of my mc and this only appears a long way down from the mc. But if i use your box_mc with the same code it works fine which tells me the codes are cool but its a mc problem.......very odd.......any ideas?

Anonymous,
Check to ensure your movieclip is registered at 0x and 0y. Also check that the mc you are reflecting is not scaled - it must be 100%. The items within the mc however, may be scaled.

It cause a high loading of the CPU ~

Awesome work, I really have to thank you for this.

But I'm having a little flickr sometimes when using this while loading the swf to a movieclip.

anyone had the same problem or have any idea why this happens?

I have been successfully using this awesome class - many thanks!
I do run into a problem though, if the reflected movieclip has several frames inside or if there is a tween inside the movieclip. Is this expected and do you know of a workaround? I tried creating a nested clip that contained the tweens but that did not work. I always place the script outside the clip at frame 1. Placing it in the clip's onClipEvent(load) { } event also did not work. :-(

Natacha - can you send me a sample FLA to test out? Thanks!

Hello Sarge,

I have uploaded a sample zip (flash CS3 file) here:

http://www.buildingblock.com.au/reflect_sample_code.zip

The video layer works.
(remove the guide setting on the layer to review)

The image layer does not work.
I thought it was if there was a tween in the clip, but I have reproduced the problem with this (seemingly) basic movieclip.

Thanks again.
Natacha

Natacha - I figured it out. Check the zip out here:
http://www.pixelfumes.com/blog/aug07/refNatacha.zip

Check out the jpg screenshot in there for an explanation. Basically your image was "group masked". Take a look.

Thanks very much for taking the time to check out the problem - I am always amazed at the open source community out there and where you guys find the time :-P

So from your response I take it I cannot mask a larger image then reflect that clip? (even by nesting this clip within other movieclips?

The reason I was using the large image is that this was in a nested clip that had tweening (ie the large image pans slowly from left to right).

So I take it that it is not possible to reflect a clip that contains an animation contained within a masked area?

Natacha - yes - that is correct. The class could be easily modified to handle other situations too. Feel free to play around with it!

wondering is theres a way of stopping and starting the reflection from updating. so it uses less CPU. great class BTW.

Hi,

I am sure this is all a little old to you now, but I have used the class in a basic way before and loved the results, so I hope you can help. I have a very simple xml slideshow (just fading images) running into an empty movie clip. When I try to reflect the imageLoader clip it fails, I assume because the clip is reflecting before the images load into it?

I read comments with your advice to preload, but being a bit of a muppet with AS2, or indeed 3, at this stage, I have struggled with linking the preload to the class.

I am back to the very basic stage at the moment, code is;

imageLoader.loadMovie("slideshow_as.swf");
import com.pixelfumes.Reflect;
r1 = new Reflect({mc:imageLoader, alpha:85, ratio:255, distance:1, updateTime:.33, reflectionAlpha:90, reflectionDropoff:1});
r1.setBounds(480,imageLoader._height);

Which of course doesn't work! Any advice would be great.

Cheers,

Will

I love this class!

But, I have a problem....

I'm dynamically adding FLVPlayback complonents in to an mc that is being reflected. when I do, the reflection stops working.

If I use a video symbol instead, then I get the reflection. However I don't want to use this as I am using other playback components and don't fancy the idea of writing these from scratch.

any help greatly appreciated!

w33b

w33b,
Can you send me a sample FLA to test your problem out? sgtpritchard at gmail.com Thanks.

Thanks so much, I love it when smart people can help me out. Designing is one thing, but coding hurts my brain.

One question, is there any way to skew the reflection, or to put some perspective into it?

There are ways to skew the reflection using Matrix Transforms. I have some stuff I worked on here but nothing ready for release. Back in the day someone had done it with an old version of this class. Maybe someone will take it upon themselves to add the functionality :).

I had to remove this from a website I am launching tonight due to very high CPU usage. Not so bad in IE, but Firefox will crawl to a stop when reflecting about 15 movieclips. It has to be due to the interval. An option to turn that off would be great.

j-sizzle - there is an option to do that already. Set the update time to 0.

Aha! Should havee looked a little harder. Thx!

This is great!

I am using a class named: AFC_Reflection But your class is more robust than this.

There is a problem with that class; when my movie moves up, I have to chance the reflection distance manually...

Does your class can handle it or works as the same with AFC_reflection class?

Sorry, this functionality is not currently in the class.

Nice work!

If the registration point of the movie clip is not 0,0 the reflection doesn't work. Do you have any sugestion?

Thanks!

Regarding turning off reflection updating: In a previous post the solution was to set updateTime = 0.

I'm doing this and it's not working. What am I doing wrong?

r1 = new Reflect({mc:maincontent, alpha:35, ratio:27.3, distance:0, updateTime:1, reflectionAlpha:100, reflectionDropoff:0});

and further down the timeline, when I want to stop updating, I do this:
r1.updateTime = 0

Reflection keeps updating and eating CPU.

Hi!
I'm developing a gallery using AS2 and have used your fantastic reflection class to achieve mirroring.
It works fine, when I use the correct URL (http://www.mydomain.com). But when I try to call the images from a sub-domain (http://pictures.mydomain.com) or from a incomplete URL (http://mydomain.com) the reflection does not appear. I put a crossdomain.xml to the root of the server but it didn't work.
System.security.loadPolicyFile script also placed in the code.
Any idea what's the problem?

Cheers!
oliver
email4you{at}email{dot}de

oliver,
I don't have much experience with cross domain policies but that would be my first guess - especially if through the IDE you get errors saying such. Otherwise is it potentially a pathing issue? Sorry to be of so little help.

Oliver, you need a cross domain policy file on the server from which you are loading the image you want to apply the reflection to. Adobe does not allow bitmap data operations on images loaded from other domains unless the policy file is there and is loaded ahead of time.

http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000353.html

@sarge, @pk
Thanks for your reply!
@pk I added a crossdomain.xml to the server but I have still the same problems. I'm using ActionScript 2 but the sample is for ActionScript 3. I'm at my wits' end ;-)

Cheers!
oliver
email4you{at}email{dot}de

The way ive been doing the update is r1.updateTime:-1. I havent noticed any slow downs.

I can one erro and need help.
The class or interface

'com.pixelfumes.Reflect' could not be loaded.

Leo

Leotaku, please ensure that you have the Reflect.as file nested in the proper directory structure and co-located to your FLA file. For example, the Reflect.as file needs to be nested in a com > pixelfumes folder. If you download the example files and extract them while maintaining the directory structure everything should be in the correct place. Thanks!

Thank you now if I me work.
Regards Leotaku (Bs As Argentina)

first off let me say...cool!

I want to reflect all...not only one movie.

Is it possible to reflect a movie with movies inside?

gr. LT

LT, you can create multiple instances of the Reflect class for each individual movie clip (e.g. r1, r2, etc). The simplest way would be to nest each clip to be reflected into one parent clip and then just have one reflect on the parent clip thus reflecting all of the clips inside as well. Either way would work.

proberly I did something wrong..It works now. Thnx voor de quick reply.

I tried putting the update to 0 but its still running heavy. On my own comp. it runs oke but when I test it on a P4 motion tweens are running very slow etc. CPu at 60/70%
I am not reflection a video...

Is there a solution to fix this.

LT, 0 would actually be the fastest update time you could use and thus the most processor intensive. A higher time will sample the reflection less often and improve performance. An update time of -1 will not update the clip at all and will have the lowest CPU usage.

As in another post comment stated I've modified this class a little bit to support a blur effect. Additionally the reflection will be send down to the lowest depth in the container so all your items keep in front of it. This is useful for distance < 0.
Furthermore I cleaned up the code to prevent warnings in the FDT. :-)

my blog posting

I am loading pictures from an xml file via a loop. What is the best way to use this class to get a reflection on the dynamically loaded pictures?

Ben,
Apply the reflections to each picture after the load of each picture is complete - only then. One other option is to load the pictures into a parent clip and simply reflect only the parent clip - again, you may need to wait until all assets are loaded before trying to reflect anything. Hope this helps!

hi, great class first off. I want to know if there is anyway to reflect more then one movieClip, without copying the code over and over. is there a way that i can tell the class to reflect multiple movieClips?

bboyrush1234, the simplest down and dirty way to do that would to be to nest all clips you wish to reflect into a wrapper clip then simply reflect the wrapper - make sense?

I had problems when using this class with flickering in firefox and opera on pc. I'm going to look into what was causing this, just wanted to alert the developers out there that if they have flickering and strange rendering behaviour in firefox and opera on pc then try removing this class. I like the effect and will do my best to get to the root problem.

Hi,

at first very cool class!

I have the refelction working fine on PC! But on my Mac neither with Safari nor Firefox the reflection is shown?!

Is there a known Problem in some constellations that the reflection is not shown on a Mac (Safari/Firefox)?

regards marcus

Marcus, it shouldn't matter. I would make sure that you have Flash 8 or higher installed in your other browsers (Flash 9 if using the AS3 version) If you still have problems you can email me your FLA at sgtpritchard at gmail.com

Hi sarge,

thanks for your quick reply.

I just found out what was wrong.

Due to design and the image I wanted to reflect, I have to change the x-position of the reflection.

Shame on me ... I tried some changes on reflectionBMP.x value in line 71, which worked well for the PC but crashed on my mac...don't know why?!

Is there a save way to adjust the x-position of the reflection relative to the image.

Thanks in advance and
kind regards
marcus

Marcus, yes you can do so. You can either modify the Reflect class or do it after the fact by targeting the nested items that are created by the class. You will likely have to open the class and find what it is you wish to move. There is currently no method to do so built into the class.

Hi it's a great class...I like it.
But I would like create a Empty movie clip and riflect a external swf
I tried but unsucsfull
please help me
thanks Tony
on the timeline:


import com.pixelfumes.Reflect;
var loadListener:Object = new Object();
loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
r = new Reflect({mc:target_mc, alpha:85, ratio:255, distance:1, updateTime:0.33, reflectionAlpha:90, reflectionDropoff:4});
}

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip("test.swf", mc);

Hi Sarge, thanks for this grat class, I like it so much...
But I would like, if you can, the best way to apply the reflect to external swf. Can you help me?
thanks Tony
I tried with this code:

import com.pixelfumes.Reflect;
var loadListener:Object = new Object();

loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
r = new Reflect({mc:target_mc, alpha:85, ratio:255, distance:0, updateTime:0.33, reflectionAlpha:90, reflectionDropoff:1.85});
}
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip("movielogo.swf", mc);

Tony, ensure the clip is on the same domain as you and ensure that it is completely loaded prior to invoking the reflection. It should help you out. Thanks.

Hi,

Through kirupa.com I came across your site and I've got a question concerning the file Reflect.as

I've got a mc with instance name 'target'. Within this mc, I've added a dynamic textfield which gets its content through a XML file.

On a second layer (called script), I've added this script:

import com.pixelfumes.Reflect;
new Reflect({mc:target, alpha:85, ratio:255, distance:1, updateTime:0.33, reflectionAlpha:90, reflectionDropoff:7});

The .as file is in the same folder as the .fla and .swf. When I test the movie, I get the following error:

The class or interface com.pixelfumes.reflect could not be loaded

Could you help me getting this to work?

Hi Sarge,

First of all thanks for the great coding...

The problem im facing is how much CPU it takes up, its lagging all my flash work... Is there anyway to fix this?

import com.pixelfumes.Reflect;

//don' apply effect to video until it is loaded
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.stateChange = function(eventObject:Object):Void {
if(video_mc.video.state == "playing" && !r1){
r1 = new Reflect({mc:video_mc, alpha:40, ratio:255, distance:-46, updateTime:0.80, reflectionAlpha:60, reflectionDropoff:3});
update();
}
}
video_mc.video.addEventListener("stateChange", listenerObject);

^^ is the code im using?

The Reflection is pretty processor intensive. I know you probably don't want a slower update time either. Your code looks good. I would just ensure that the listener is only creating 1 instance of the reflection. the code appears to do so but that is the first thing I would check.

I am trying to add a reflection to my coverflow classs... u mind taking a look at the fla.. cause its not work for some odd reasons

Sure, send the fla to sgtpritchard at gmail.com

Thanks - It's sent so it should be in your inbox.

First I want to say that I am extremely grateful for the class.
It's saved me a day or two this week.

Now, I think my issue is that you can't reflect things that have been skewed using bitmapdate.

Is there a way around that?

I'm not sure the last time someone commented this. But I found this class EXTREMELY useful for a project I was working on, except that I needed to have the reflection applied to a masked movieclip. I changed up the class slightly so that the reflected movieclips are added to the parent MC as opposed to the movieclip that is being masked. Swap out the top block of code for this block of code. I still need to alter it to making this an option as opposed to forcing this feature, but this should do for now until I have time. Enjoy.

var mc_c:MovieClip = args.mc;
var mc:MovieClip = mc_c._parent;

var alpha:Number = args.alpha;
var ratio:Number = args.ratio;
var updateTime:Number = args.updateTime;
var reflectionAlpha:Number = args.reflectionAlpha;
var reflectionDropoff:Number = args.reflectionDropoff;
var distance:Number = args.distance;

//class reference to reflected clip
clip = mc_c;
var mcHeight = (mc_c._height/mc_c._yscale)*100;
var mcWidth = (mc_c._width/mc_c._xscale)*100;
//
bounds = new Object();
bounds.width = mcWidth;
bounds.height = mcHeight;
//
var matrixHeight:Number;
if (reflectionDropoff<=0) {
matrixHeight = bounds.height;
} else {
matrixHeight = bounds.height/reflectionDropoff;
}
//
mcBMP = new BitmapData(bounds.width, bounds.height, true, 0xFFFFFF);
mcBMP.draw(mc_c);
//
reflectionBMP = new BitmapData(bounds.width, bounds.height, true, 0xFFFFFF);
reflectionBMP.draw(mc_c);

Very very nice, works perfectly in Flex on Air. many thankyous

Hi!
Is there a copyright on the reflection - class?
Where can i get information about that?
Thanks

Hello^^

This is very cool! Now i try to use this Class in a Papervision3D Projekt but it doesent work. I think i must use a Plane as the Target Mc but it doesent work.

Can please someone tell me how to use this Class in Papervison3D ??

Thanks alot!!!

Trail, there is no copyright though I would love a shoutout, commented line or link back. But none of that is really a must. Thanks for your interest.

can anyone can plz give the best example for the FULLSCREEN in flash. ..

Very nice work!!!
but i have a question : how can i reflect a dynamic text (preload count) into a movie clip ??
Thank you

Ben,
You would simply nest the text field in a movie clip and then use the class on the movie clip containing the text field. That should work for you. If not, let me know.

Very nice effect but I can not get it works for video. Can anybody help? Where can I send my fla?

Natalia, there is a zip file at the top of the post that links to this file: http://www.pixelfumes.com/blog/mar07/Reflect%20V3.zip. In it is a demo FLA using video. Take a look and see if that helps. Make sure your video has loaded completely before trying to reflect it.

I think I don't understand something. I use progressive dowload. Here is a code:

import com.pixelfumes.Reflect;
var nc:NetConnection=new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
ns.setBufferTime(3);
ns.onStatus=function(info){
if (info.code=="NetStream.Buffer.Full"){
bufferClip._visible=false;
}
if (info.code=="NetStream.BufferEmpty"){
bufferClip._visible=true;
}
if (info.code=="NetStream.Play.Stop"){
ns.seek(0);
r1 = new Reflect({mc:theVideo, alpha:85, ratio:255, distance:1, updateTime:.33, reflectionAlpha:90, reflectionDropoff:7});
}
}
theVideo.attachVideo(ns);
ns.play("privet/video/flv/irena.flv");

Natalia,
I think it was because you were trying to reflect a video symbol and not a MovieClip. Try the files here:
http://www.pixelfumes.com/blog/mar07/ReflectNS.zip

I did exactly as you say and nothing. Can you look?
http://www.natavi.co.uk/reflect/test.zip
Thank you very much for your help.

Hi Ben
Can you help me with this file where I use your class
http://www.natavi.co.uk/reflect/test.zip

Thank you very much.
Natalia
nata_vikh@yahoo.com

Natalia, I sent you an updated FLA. Thanks!

Hi! Super great class by the way..!, I just wondered if it´s possible to have two reflections (like www.nike.com) one above and one at the bottom. Is this possible?? Thanks in advance!
And again, GREAT class!
Regards
Diego

Diego, currently the class does not support that but it could be re-written to do so fairly quickly i fyou feel up to the task.

Hi! This is karunakar.I have loaded 16 images using xml file.I want the reflections to those images.pease send me a reply.

Thanks.

Like this class but I'm having trouble using it. I don't get any errors, and I can even see the 2 movieclips it created on my MC when I use the ActionScript debugger, but I can't actually see the reflection. The debugger showed the MC with 100 alpha but still can't see it. Could really use some help fast, thanks

To change the update time (to lower CPU usage) of a reflection, I added a small function to the Reflection Class.

I'm not a big flash expert, so correct me if I'm doing something not 100% correct. It's working for me :-)

public function changeUpdateTime(time : Number):void {
timer.stop();
timer = new Timer(time);
timer.addEventListener(TimerEvent.TIMER, update);
timer.start();
}

An example on how to use it:

r1.changeUpdateTime(-1); // This example stops the refreshing of a certain reflection - with r1 the variable containing the reflection

Nicholas, send me your FLA and I will take a look. sgtpritchard at gmail.com Thanks.

I've found the update process is very cpu intensive in my project for some reason, setting updateTime as -1 didn't help. But I found this line in Reflect.as:

if(updateTime != null){
updateInt = setInterval(this, "update", updateTime, mc);
}



So I set it to 'null' and bingo! Hopefully this'll save someone a couple of hours!

this is really great code .... i was finding a same for making a product showcase

thanks a ton will try this one soon now.

i had problem using this ...i just create a simple instance of movie clip but reflection doesn't shows up..then i tried copying your examples library object and replace my element into that..i am using flash 8....moreover i have a wmf logo...i tried on this its reflection is not upto the mark ...dont know what is the problem please help....

can you suggest what is the problem with this

http://www.mediafire.com/?w2yuhj2kt0m
http://www.mediafire.com/?tw25lzmt4tz

Euphoric,
I fixed the files for you. They are temporarily available here:
http://pixelfumes.com/uploads/reflect_9-22.zip

Check out this post to see what was causing the problems:
http://pixelfumes.blogspot.com/2007/07/helpful-tips-for-using-pixelfumes.html

Mainly it was the scale on the primary clip being reflected as well as not having a 0x,0y registration.
-Ben

thanks ben ....you are great

i checked on to reg 0x,0y it worked fine then on..thanks for help..and it would be much better if you could add link to the helping note in this post or steps itself...

between i am still having a prob preloading image before reflection class....i have used function to check preloading but reflection isnt happening...

between i just tumbled code here and there and used stimulate download in flash player i found image reflection was coming and also loading earlier to image load in a case....but in my final code nothing is happening....i dont know how to use addEventlistener in as2 please help..

flash file
http://www.mediafire.com/?tmzj3fwcij4
xml file
http://www.mediafire.com/?nz34zywc2y1

Euphoric,
Try this:
www.pixelfumes.com/uploads/reflect_9-23.zip

tanks a ton ben you are really helpful guy

Im having trouble using this classes on my MAC, could anyone make me a walkthrough of the steps to do so this thing work on mac? i think i missed a step somewhere!

Thanks

Hi I'm having trouble installing this on a MAC environment could anyone help me out with a step by step for mac user? Thanks in advance!

Olivier, the code will not run any differently on a Mac than it will on a PC. What are you trying to attempt?

I keep getting a 1046 error, it says type was not found or compile time error

nevermind I was publishing it in as3, didnt realize it was as2, any plans for an as3 version?

i think this one is very very useful,, well i saw the reflections ^^ but i can't seem to fix the reflection.... it's like passing through my movie clip,, well is there a problem if the mc is moving on different directions? like up---down(center) then center to left.... :P thank BTW,,,

This is GREAT!!! My only issue is - I have a picture inside a mc to be reflected. height it works great but for the width it only reflects half of the picture?

Hi Ben,

Thanks for writing this class and getting it out there. I have been using it for a while in the development of a new site and there is just one snag I have come across.

I create the reflection on the first frame of my site and also have a section in the site which displays images, you can click an image and you are taken to a keyframe in the movie where there is no reflection and the image fills the screen. You then click 'back' which returns you to where you came from and the reflection class is called and makes the refelction visible again. However, when you return everything crunches up and runs really slow and jittery at less than half the frame rate.

I have tried various things but cannot seem to get it running smoothly. Any ideas as to what may be happening? Is there a way to clear the memory for example or to redisplay the reflection without having to use the whole "new Reflect ({mc:video_mc, alpha:68........" code ? I can't post an example due to client confidentiality I am afraid but any ideas would be much appreciated.

Thanks,

James

Hey Ben. Nice class, though after going over it closely I did notice something. reflectionBMP seems to be completely superfluous. While it does draw the source MovieClip, mc, it never gets attached anywhere, so it is just a BitmapObject living in memory. mcBMP, on the other hand, draws the source clip and them gets attached to reflection_mc, and this is what we see as the reflection. If you remove all references to reflectionBMP in the class you get an average 12% jump in performance (on my machine) b/c the superfluous Bitmap operations being called on it don't occur, but everything still works perfectly. Of course I may be missing something, and if so I apologize for my presumption, but for the bump in performance I thought that it was worth mentioning.

Rawle - Wow - I think you are correct. I haven't looked at this code in some time. Great find! I think I need to release a v4 to fix this and add some other tweaks! Thanks for the post!

Hello,

Wonderful actionscript you have here! Unfortunately I keep getting an error on my flash movie:

5007: An ActionScript file must have have at least one externally visible definition.

I have no idea what this means nor how to fix it but hopefully you can give me some insight. I know nothing about actionscript so hopefully you can dumb it down for me! :)

FYI..I have a very simple movie.

1 MovieClip called video_mc with the instancename as video_mc as well.

Within that video_mc I have other movie clips.

I saved my .fla and published my .swf to a folder. Within that folder I have the com folder which I downloaded which holds the .as file (inside the pixelfumes folder)

Everything seems to be in order but for some reason I cant get it to work! Thank you for any help!

Mark

I forgot to mention I am using Flash CS4 with actionscript 3.

Thank you,

Mark

Mark, this is the AS2 version of the class - that would be one reason why you are having problems. Try the AS3 version here: http://www.adobe.com/devnet/flash/articles/reflect_class_as3.html

i have a big problem with that component. I have a movieclip in which i load several small clips.
this movieclip gets wider that 2879 pixels. i slide that movie backward and forward and i need to reflect it.
bigpicturecom.de --> communication --> projekte.
what i set the bounds to 2879 it works. 2880 makes no gradient in reflection and all above doesnt work.
is there a possibility to reflect just what i see so just the width of the main movie? that would be 800 px ... :-) i hope you can help

i have the same problem. It's seems that the heigth and the width of the moviclip it's not passed correctly to the class. So you maybe have to modify the class itself.

I use a little trick, altough i don't like it: i modify the mc.width adding extra pixel to the width value. But i really want to solve this issue.

a way we can solve our problem is to
just make the reflection as big as the stage and slide the other movie.
it works but doesnt look so good.

the second way would be to add a second reflection when the movie becomes too big.

I get an error saying Reflect.as, Line 1 5007: An Actionscript file must have at least one external visable definition

I am also having an issue with this class. I'm looping through an array and attaching a group of thumbnails into a mc I created on the fly. I'm then duplicating the clip that contains all of the thumbnails for the reflection. Unfortunately, for all of the clips containing the thumbnails, the last thumbnail doesn't have a reflection. In fact, it even looks like the second to last one fades out on the right before it gets to the final thumbnail. I'm not sure why this is happening, or how to go about resolving it and was hoping that I could get some help if possible.

Michelle make sure you are meeting all the "tips" for using the class found here:http://blog.pixelfumes.com/?p=174 and see if that helps.

I actually saw that the other day. I am meeting all of those requirements. The movie clip is generated dynamically so the registration point should automatically be 0,0. I'm not scaling, and all of my images are brought in locally from a folder on my desktop and an XML file. I found another reflection class that I used and that worked, but I would rather not use that one because I don't think it's as fine-tuned as yours. So I'm not sure if it's a class issue or a flash issue on my end since I got it working another way.

Man, I feel stupid.

I can't get the reflection class to work.

I'm in AS2, publishing to 8, 9 and 10 and can't get the reflection to show.

I've got the folder structure exactly the same.

Is there a piece of the puzzle that I'm missing?

Thanks.

Ohh duh on me!

It was a registration point issue. I didn't have the object within my mc at 0x 0y.

They were right, reading is golden.

:)

Thanks

Post a Comment