I am using a movie clip prototype (see below) to blur my navigation when the user rolls over it. It works, but i would like for it to just blur once, then go back to being clear, all while the mouse is over it. Any suggestions? Thank you :0) MovieClip.prototype.blurMC = function(){ var b:BlurFilter = new BlurFilter(); this.filters=[b]; this.onEnterFrame=function(){ this.onRollOver = function(){ this.val = true; } this.onRollOut = function(){ this.val = false; } if(this.val){ b.blurX +=1; if(b.blurX > 4){ b.blurX = 4; } b.blurY = b.blurX; this.filters = [b]; }else{ b.blurX -=1; if(b.blurX < 0){ b.blurX = 0; } b.blurY = b.blurX; this.filters=[b]; } } }; myNavMC.onEnterFrame = function(){ myNavMC.blurMC(); }
there are a few problems with that code. i think you'd be better served using the following. MovieClip.prototype.blurMC = function() { if (!this.blurFilter) { this.blurFilter = new BlurFilter(); this.filters = [this.blurFilter]; } if (!this.childMC) { mc = this.createEmptyMovieClip("child12341324MC", this.getNextHighestDepth()); mc.b = this.blurFilter; } mc.b.blurX = 2; mc.onEnterFrame = function() { if (!this.blurOut) { this.b.blurX += 2; this.b.blurY = this.b.blurX; this._parent.filters = [this.b]; if (this.b.blurX>=8) { this.blurOut = true; } } else { this.b.blurX -= 2; this.b.blurY = b.blurX; this._parent.filters = [b]; if (this.b.blurX<=2) { this.b.blurY = this.b.blurX=0; this._parent.filters = [this.b]; this.blurOut = false; delete this.onEnterFrame; } } }; }; // and use rollOver handlers to call the blurMC method: myNavMC.onRollOver = function() { this.blurMC(); };
the main problems with the previous code were: 1. you were (trying to) repeatedly calling blurMC (with myNavMC.onEnterFrame) and that's not necessary. blurMC creates a loop to gradually (actually pretty quickly) blur the movieclip. 2. the loop in blurMC never ends. for each movieclip to which it's applied it initiates an onEnterFrame loop that never terminates. 3. the loop blurMC started was applied to the movieclip itself. if the movieclip already had an onEnterFrame loop defined, blurMC would replace that loop breaking your code elsewhere. (though this worked to your advantage with your original code where myNavMC.onEnterFrame would have caused the flash player to go into an endless loop and crash if it weren't replaced.)
wow, thanks. it is always nice to know what is wrong so that you don't do it again :0)
Don't see what you're looking for? Try a search.
|