Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reflections in flash?

Status
Not open for further replies.

lastingforhours

Programmer
Dec 29, 2004
49
0
0
US
you know how apple has popularized the reflection?

reflection_thumb.jpg


well, is there a way to do that with actionscript in flash? id love to make a photo gallery that dynamically loads photos and then creates the reflection at runtime. would it even be practical to do it that way? am i making this harder than it has to be haha? thanks in advance.

--
Matt Milburn, Wave Motion Studios
matt@wavemotionstudios.com
 
You can just flip the image and apply gradient layer on top. To do this purely in ActionScript, it would be something like:

[tt]// AS2 main timeline
var jpeg:String = "test.jpg";
//
var loadCount:Number = 0;
this.createEmptyMovieClip("mcImg", 1);
this.createEmptyMovieClip("mcRef", 2);
var mcl:MovieClipLoader = new MovieClipLoader();
var lo:Object = new Object();
mcl.addListener(lo);
lo.onLoadInit = function():Void {
loadCount++;
};
mcl.loadClip(jpeg, mcImg);
mcl.loadClip(jpeg, mcRef);
this.onEnterFrame = function():Void {
if (loadCount>1) {
reflection();
delete this.onEnterFrame;
}
};
function reflection():Void {
with (mcRef) {
_yscale = -100;
_y = _height*2;
_alpha = 70;
}
var maskW:Number = mcRef._width;
var maskH:Number = mcRef._height;
this.createEmptyMovieClip("mcMask", 3);
with (mcMask) {
colors = [0xffffff, 0xffffff];
fillType = "linear";
alphas = [0, 100];
ratios = [0, 100];
matrix = {matrixType:"box", x:0, y:0, w:maskW, h:maskH, r:Math.PI/2};
beginGradientFill(fillType, colors, alphas, ratios, matrix);
moveTo(0, 0);
lineTo(maskW, 0);
lineTo(maskW, maskH);
lineTo(0, maskH);
lineTo(0, 0);
endFill();
_y = maskH;
}
}
//[/tt]

You can do differently with Flash 8 BitmapData class as well.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top