import flash.display.BitmapData; class oxylus.carousel.Thumbnail extends MovieClip { private var Brd:MovieClip; private var Msk:MovieClip; private var Img:MovieClip; private var Rfl:MovieClip; private var RMsk:MovieClip; private var Tip:MovieClip; private var w:Number; private var h:Number; private var _reflections:Boolean = true; private var _showBorder:Boolean = true; private var _showTooltip:Boolean = true; private var node:XMLNode; private var mcl:MovieClipLoader; public var onMouseOver:Function; public var onMouseOut:Function; public function Thumbnail() { Brd = this["mc0"]; Msk = this["mc1"]; Tip = this["mc2"]; Tip._alpha = 0; Img = this.createEmptyMovieClip("_img_", this.getNextHighestDepth()); Img._x = Msk._x; Img._y = Msk._y; Img._alpha = 0; w = Msk._width; h = Msk._height; Msk._alpha = 0; this.hitArea = Msk; Brd._alpha = 0; this._visible = false; mcl = new MovieClipLoader(); } private function fadeTo(mc:MovieClip, al:Number) { var p:Number = 10; mc.onEnterFrame = function() { if (Math.abs(this._alpha-al)<=p) { this._alpha = al; delete this.onEnterFrame; return; } if (this._alpha>al) { this._alpha -= p; } else { this._alpha += p; } }; } private function onRollOver() { if (_showBorder) { fadeTo(Brd, 100); } if (_showTooltip) { fadeTo(Tip, 100); } onMouseOver.call(this); } private function onRollOut() { if (_showBorder) { fadeTo(Brd, 0); } if (_showTooltip) { fadeTo(Tip, 0); } onMouseOut.call(this); } private function onRelease() { getURL(node.attributes.link, node.attributes.target); } private function onReleaseOutside() { onRollOut(); } public function setData(n:XMLNode, s:XMLNode) { node = n; _reflections = s.attributes.reflections == "yes"; _showBorder = s.attributes.showBorder == "yes"; _showTooltip = s.attributes.showTooltip == "yes"; if (_showTooltip) { var TipBody:MovieClip = Tip["mc0"]; var TipText:TextField = Tip["mc1"]; TipText.autoSize = "center"; TipText.text = node.attributes.tooltip; TipBody._width = Math.round(TipText._width); TipBody._x = -Math.round(TipBody._width/2); } else { Tip.swapDepths(this.getNextHighestDepth()); Tip.removeMovieClip(); } var buf:MovieClip = this.createEmptyMovieClip("_buf_", this.getNextHighestDepth()); buf._visible = false; mcl.addListener(this); mcl.loadClip(node.attributes.src, buf); } private function onLoadInit(buf) { var bd:BitmapData = new BitmapData(w, h, true, 0); bd.draw(buf); buf.removeMovieClip(); Img.attachBitmap(bd, Img.getNextHighestDepth(), "auto", true); fadeTo(Img, 100); if (_reflections) { Rfl = this.createEmptyMovieClip("_ref_", this.getNextHighestDepth()); Rfl.attachBitmap(bd, Rfl.getNextHighestDepth()); Rfl._alpha = 0; Rfl._yscale = -100; Rfl._x = Img._x; Rfl._y = Img._y+2*h; Rfl.cacheAsBitmap = true; RMsk = this.attachMovie("TransparencyMask", "_ref_msk_", this.getNextHighestDepth()); RMsk.cacheAsBitmap = true; RMsk._alpha = 20; RMsk._width = w; RMsk._height = h/3; RMsk._x = Img._x; RMsk._y = Img._y+h; Rfl.setMask(RMsk); fadeTo(Rfl, 100); } this._visible = true; } public function get width() { return w; } public function get height() { return h; } }