class studio.main extends MovieClip { var img, rect, pt, mapBmp, blurredMapBmp, blurF, dispMapF, onMouseDown, _xmouse, _ymouse, tmp, onMouseUp, onMouseMove, spot, onEnterFrame, onPress, createEmptyMovieClip, mapHolder; function main() { super(); rect = new flash.geom.Rectangle(0, 0, Math.floor(img._width), Math.floor(img._height)); pt = new flash.geom.Point(0, 0); mapBmp = new flash.display.BitmapData(rect.width, rect.height, false, 8421504); blurredMapBmp = mapBmp.clone(); blurF = new flash.filters.BlurFilter(8, 8, 2); dispMapF = new flash.filters.DisplacementMapFilter(blurredMapBmp, pt, 2, 4, 100, 100, "clamp"); } // End of the function function onLoad() { this.configUI(); } // End of the function function configUI() { onMouseDown = startStudio; } // End of the function function startStudio() { tmp = {oldx: _xmouse, oldy: _ymouse}; onMouseUp = endStudio; onMouseMove = gooify; } // End of the function function endStudio() { delete this.tmp; delete this.onMouseUp; delete this.onMouseMove; } // End of the function function clearStudio() { mapBmp.fillRect(rect, 8421504); blurredMapBmp.fillRect(rect, 8421504); this.applyMap(); } // End of the function function gooify() { var _loc3 = _xmouse - tmp.oldx; var _loc2 = _ymouse - tmp.oldy; tmp = {oldx: _xmouse, oldy: _ymouse}; spot._rotation = Math.atan2(_loc2, _loc3) * 180 / 3.141593E+000; spot._x = _xmouse; spot._y = _ymouse; var _loc6 = 128 + Math.min(121, Math.max(-128, -_loc3 * 2)); var _loc4 = 128 + Math.min(121, Math.max(-128, -_loc2 * 2)); var _loc5 = new flash.geom.ColorTransform(0, 0, 0, 1, 128, _loc6, _loc4, 0); mapBmp.draw(spot, spot.transform.matrix, _loc5, "hardlight"); this.applyMap(); } // End of the function function applyMap() { blurredMapBmp.applyFilter(mapBmp, rect, pt, blurF); img.filters = [dispMapF]; } // End of the function function animateStudio(){ onEnterFrame = animate; onPress = endAnimate; delete this.onMouseDown; var val = 100*_root.tTimeFrame.value; tmp = {count:val,dir:-4,scale:dispMapF.scaleX,val:val}; } // End of the function function animate(){ tmp.count = tmp.count + tmp.dir; if (tmp.count >= tmp.val || tmp.count <= 0) { tmp.dir = tmp.dir * -1; } // end if dispMapF.scaleX = dispMapF.scaleY = tmp.count / tmp.val * tmp.scale; this.applyMap(); } // End of the function function endAnimate(){ delete this.onEnterFrame; delete this.onPress; dispMapF.scaleX = dispMapF.scaleY = tmp.scale; onMouseDown = startStudio; delete this.tmp; this.applyMap(); } // End of the function function showMap(){ mapHolder = this.createEmptyMovieClip("mapHolder", 2); mapHolder.attachBitmap(mapBmp, 2); onPress = hideMap; } // End of the function function hideMap(){ mapHolder.removeMovieClip(); delete this.onPress; } // End of the function static var CLASS_REF = studio.main; static var LINKAGE_ID = "studio.main"; } // End of Class