1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: |
import flash.geom.Matrix;
import flash.filters.BlurFilter; class MyCloud{ var mc,mcSrc:MovieClip; var arUnit,arFilter,arParamGradationColors,arParamGradationAlphas ,arParamGradationRatios:Array; var nTimerHide,nSegment,nSpanX,nStepGradation ,nAlphaMax,nPositionX:Number; var oMatrix:Matrix; function MyCloud(mcSrcIn:MovieClip){ this.mcSrc = mcSrcIn; this.mc = _root.createEmptyMovieClip('mcCloud',_root.getNextHighestDepth()); var owner:Object = this; this.mc.onEnterFrame = function(){owner.McOnEnterFrame();} this.nSpanX = 64; this.nSegment = Math.floor(Stage.width / this.nSpanX) + 2; this.nStepGradation = 20; this.nAlphaMax = 60; this.arUnit = new Array(); for(var i=0;i<this.nSegment;i++)this.arUnit.push(new MyCloudUnit(this.arUnit)); this.arParamGradationColors = new Array(0xFFFFFF,0xFFFFFF); this.arParamGradationAlphas = new Array(0x00,0x00); this.arParamGradationRatios = new Array(0x00,0xFF); this.arFilter = new Array(new BlurFilter(10,10,1)); this.oMatrix = new Matrix(); } function McOnEnterFrame(){ for(var i=this.arUnit.length - 1;i>0;i--)this.arUnit[i].Update(); this.arUnit[0].y = this.mcSrc._y; this.nPositionX = this.mcSrc._x + this.mcSrc._width; this.mc.clear(); for(var i=0;i<this.arUnit.length - 1;i++){ this.CalcGradation(i); this.DrawGradation(i); } this.mc.filters = this.arFilter; } function CalcGradation(i){ this.arParamGradationAlphas[0] = i * this.nStepGradation; this.arParamGradationAlphas[1] = (i + 1) * this.nStepGradation; if(this.arParamGradationAlphas[0] > this.nAlphaMax)this.arParamGradationAlphas[0] = this.nAlphaMax; if(this.arParamGradationAlphas[1] > this.nAlphaMax)this.arParamGradationAlphas[1] = this.nAlphaMax; this.oMatrix.createGradientBox(this.nSpanX,0,0,this.nPositionX,this.arUnit[i].y); } function DrawGradation(i){ this.mc.beginGradientFill("linear",this.arParamGradationColors, this.arParamGradationAlphas,this.arParamGradationRatios,this.oMatrix); this.mc.moveTo(this.nPositionX,this.arUnit[i].y); this.mc.lineTo(this.nPositionX,this.arUnit[i].y + this.mcSrc._height); this.nPositionX += this.nSpanX; this.mc.lineTo(this.nPositionX,this.arUnit[i + 1].y + this.mcSrc._height); this.mc.lineTo(this.nPositionX,this.arUnit[i + 1].y); this.mc.endFill(); } } |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: |
class MyCloudUnit{
var nIndex,y:Number; var arUnit:Array; function MyCloudUnit(arUnitIn:Array){ this.arUnit = arUnitIn; this.nIndex = this.arUnit.length; } function Update(){ var nNoise:Number = Math.random() * 3; nNoise -= 0.5; if(this.nIndex)this.y = this.arUnit[this.nIndex - 1].y + nNoise; } } |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: |
var oCloud:Object = new MyCloud(this.mcSource);
this.mcSource.onEnterFrame = function(){ this._xscale = 100 * _root._xmouse / Stage.width; if(this._xscale < 5)this._xscale = 5; this._yscale = this._xscale; var nParam:Number = this._xscale * 0.05; this._x = _root._xmouse - this._width * 0.5 + nParam * Math.random(); this._y = _root._ymouse - this._height * 0.5 + nParam * Math.random(); } |