# Fading Grid

**URL:** <https://forum.kirupa.com/t/fading-grid/152713>\
**Category:** Uncategorized\
**Created:** [June 27, 2005, 12:06am UTC](https://forum.kirupa.com/t/fading-grid/152713 "2005-06-27T00:06:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fritzxxx](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Fritzxxx](https://forum.kirupa.com/u/Fritzxxx)\
**Post date:** [June 27, 2005, 12:06am UTC](https://forum.kirupa.com/t/fading-grid/152713/1 "2005-06-27T00:06:41Z")

</div>

Hi all  
I need your help

just worked over the Tutorial “fading Grid” and it works fine.

here is the tutorial:  
[http://www.kirupa.com/developer/mx/fadegrid.htm](http://www.kirupa.com/developer/mx/fadegrid.htm)

BUT: I desperatly tried to trigger the script (by calling the function fadeOut() )  
with a button action and NOT with an “onEnterFrame”.

I tried everything, well it seems for a newbie like me to hard.  
Can anyone help me, triggering the script by pressing a button

Here’s the script

//Declare variables  
xspacing = box.\_width;  
yspacing = box.\_height;  
depth = 0;  
box.\_visible = 0;  
smoothness = 90;  
//Calculate positions and values  
amH = Math.ceil(image.\_width/box.\_width);  
amV = Math.ceil(image.\_height/box.\_height);  
border.\_height = image.\_height+1;  
border.\_width = image.\_width+1;  
border.\_x = image.\_x-0.5;  
border.\_y = image.\_y-0.5;  
//Create grid  
for (var k = 0; k\<amV; k++) {  
for (i=0; i\<amH; i++) {  
box.duplicateMovieClip(“box”+depth, depth);  
cur = this[“box”+depth];  
cur.\_x = image.\_x+(xspacing_i);  
cur.\_y = image.\_y+(yspacing_k);  
depth++;  
}  
}  
function fadeOut(startboxnr, speed) {  
fadeMC(startboxnr, speed);  
}  
function fadeMC(mcnr, speed) {  
this[“box”+mcnr].onEnterFrame = function() {  
this.\_alpha -= speed;  
if (this.\_alpha\<=smoothness) {  
[//this.onEnterFrame](https://this.onEnterFrame) = null;  
continueFade(this, speed);  
mcnr += 1;  
fadeOut(mcnr, speed);  
}  
};  
}  
function continueFade(mc, speed) {  
mc.onEnterFrame= function() {  
this.\_alpha -= speed;  
if (this.\_alpha\<=0) {  
//delete this.onEnterFrame;  
}  
};

}  
fadeOut(0, 25);
