P
ROTOTYPE
I'm Not Only The Prototype, I'm Also A Member.
home
▪
stats
▪
search
▪
linkback
▪
about
▪
FAQ
| user: guest,
login
,
register
Movieclip
:
dropShadow: really nice and natural one...(rectangles only!)
author:
hypeartist
[+]
,
Submitted: 09.22.04 5a
• Last Edit: 09.30.04 9p
// It's kinda my response to Quasimondo's approach...:) MovieClip.prototype.dropShadow=function(spread,offset,color){ this.spread=spread; this.offset=offset; this.col=color; this.sidesColors = [0xFFFFFF, this.col]; this.cornerColors = [this.col,0xFFFFFF]; this.ratios = [0, 255]; this.sidesAlphas = [0, 100]; this.cornerAlphas = [100, 0]; sh=_root.createEmptyMovieClip(this._name+"ShadowHolder_mc",this.getDepth()+1); this.swapDepths(sh); this.bounds=this.getBounds(this); this.x=this.bounds.xMin; this.y=this.bounds.yMin; this.bounds=this.getBounds(_root); this.w=this.bounds.xMax-this.bounds.xMin this.h=this.bounds.yMax-this.bounds.yMin; b=sh.createEmptyMovieClip("InnerBox_mc", 1); b.bounds=this.getBounds(b); b.x=b.bounds.xMin+offset; b.y=b.bounds.yMin+offset; b.w=(b.bounds.xMax-b.bounds.xMin)-spread/2; b.h=(b.bounds.yMax-b.bounds.yMin)-spread/2; b.lineStyle(1, this.col, 0); b.beginFill(this.col,0); b.drawRect(b.x,b.y,this.w,this.h); b.endFill(); sl=sh.createEmptyMovieClip(this._name+"SideL_mc", 2); this.matrix = {matrixType:"box", x:b.x-this.spread, y:b.y, w:this.spread, h:b.h, r:0}; sl.lineStyle(0, this.col, 0); sl.beginGradientFill("linear", this.sidesColors, this.sidesAlphas, this.ratios, this.matrix); sl.drawRect(b.x-this.spread, b.y, this.spread, b.h); sl.endFill(); st=sh.createEmptyMovieClip(this._name+"SideT_mc", 3); this.matrix = {matrixType:"box", x:b.x, y:b.y-this.spread, w:b.w, h:this.spread, r:Math.PI/2}; st.lineStyle(0, this.col, 0); st.beginGradientFill("linear", this.sidesColors, this.sidesAlphas, this.ratios, this.matrix); st.drawRect(b.x, b.y-this.spread, b.w, this.spread); st.endFill(); sr=sh.createEmptyMovieClip(this._name+"SideR_mc", 4); this.matrix = {matrixType:"box", x:b.x+b.w, y:b.y, w:this.spread, h:b.h, r:Math.PI}; sr.lineStyle(0, this.col, 0); sr.beginGradientFill("linear", this.sidesColors, this.sidesAlphas, this.ratios, this.matrix); sr.drawRect(b.x+b.w, b.y, this.spread, b.h); sr.endFill(); sb=sh.createEmptyMovieClip(this._name+"SideB_mc", 5); this.matrix = {matrixType:"box", x:b.x, y:b.y+b.h, w:b.w, h:this.spread, r:-Math.PI/2}; sb.lineStyle(0, this.col, 0); sb.beginGradientFill("linear", this.sidesColors, this.sidesAlphas, this.ratios, this.matrix); sb.drawRect(b.x, b.y+b.h, b.w, this.spread); sb.endFill(); clt=sh.createEmptyMovieClip(this._name+"CornerLT_mc", 6); this.matrix = {matrixType:"box", x:b.x-this.spread, y:b.y-this.spread, w:this.spread*2, h:this.spread*2, r:0}; clt.lineStyle(0, this.col, 0); clt.beginGradientFill("radial", this.cornerColors, this.cornerAlphas, this.ratios, this.matrix); clt.moveTo(b.x-this.spread, b.y); clt.curveTo(b.x-this.spread, b.y-this.spread, b.x, b.y-this.spread); clt.moveTo(b.x-this.spread, b.y); clt.lineTo(b.x, b.y); clt.lineTo(b.x, b.y-this.spread); clt.endFill(); crt=sh.createEmptyMovieClip(this._name+"CornerRT_mc", 7); this.matrix = {matrixType:"box", x:b.x+b.w-this.spread, y:b.y-this.spread, w:this.spread*2, h:this.spread*2, r:0}; crt.lineStyle(0, this.col, 0); crt.beginGradientFill("radial", this.cornerColors, this.cornerAlphas, this.ratios, this.matrix); crt.moveTo(b.x+b.w, b.y-this.spread); crt.curveTo(b.x+b.w+this.spread, b.y-this.spread, b.x+b.w+this.spread, b.y); crt.lineTo(b.x+b.w, b.y, b.y); crt.lineTo(b.x+b.w, b.y-this.spread); crt.endFill(); clb=sh.createEmptyMovieClip(this._name+"CornerLB_mc", 8); this.matrix = {matrixType:"box", x:b.x-this.spread, y:b.y+b.h-this.spread, w:this.spread*2, h:this.spread*2, r:0}; clb.lineStyle(0, this.col, 0); clb.beginGradientFill("radial", this.cornerColors, this.cornerAlphas, this.ratios, this.matrix); clb.moveTo(b.x-this.spread, b.y+b.h); clb.curveTo(b.x-this.spread, b.y+b.h+this.spread, b.x, b.y+b.h+this.spread); clb.lineTo(b.x, b.y+b.h); clb.lineTo(b.x-this.spread, b.y+b.h); clb.endFill(); crb=sh.createEmptyMovieClip(this._name+"CornerRB_mc", 9); this.matrix = {matrixType:"box", x:b.x+b.w-this.spread, y:b.y+b.h-this.spread, w:this.spread*2, h:this.spread*2, r:0}; crb.lineStyle(0, this.col,0); crb.beginGradientFill("radial", this.cornerColors, this.cornerAlphas, this.ratios, this.matrix); crb.moveTo(b.x+b.w+this.spread, b.y+b.h); crb.curveTo(b.x+b.w+this.spread, b.y+b.h+this.spread, b.x+b.w, b.y+b.h+this.spread); crb.lineTo(b.x+b.w, b.y, b.y); crb.lineTo(b.x+b.w, b.y+b.h); crb.endFill(); return sh; } // this one is surely can be put inside of the above MovieClip.prototype.drawRect = function(x, y, w, h) { this.moveTo(x, y); this.lineTo(x+w, y); this.lineTo(x+w, y+h); this.lineTo(x, y+h); this.lineTo(x, y); };
usage
[b]Params:[/b] [i][b]spread [/b][/i]- kinda blur radius [i][b]offset [/b][/i]- distance from the source [i][b]color [/b][/i]- shadow color [b]Usage:[/b] box_mc.dropShadow(10,6,0x333333); ---------------------------------------------------------------------- Enjoy! Any comments are welcome...
msg
1
{
Syncro
[+]
, posted: 09.30.04 10a•-, top
[^]
}
Neat but your dropshadows are static, try applying this proto to a moving mc.
msg
2
{
hypeartist
[+]
, posted: 09.30.04 9p•-, top
[^]
}
i've added
return sh;
statement in the prototype section, so now you can try this (though it's kinda tricky :) :
tmc=box_mc.dropShadow(9,4,0x666666); box_mc.onEnterFrame=moveIt; function moveIt(){ this._x++; tmc._x++; }
hope it'll help...
Add Comment
[+]
›opyleft 2001-2010. Layer51 is: Jaime Prado.
@