[FMX] fading grid

I did a search but haven’t found the answer to my question.

I did the fading grid tutorial and it worked out beautifully…but I was wondering how to invoke it again? I Know if you put

[AS]
on (release){
fadeOut(0, 5)
}
[/AS]

it works, but if you push the button again nothing happens? How do i get the grid to fade again?

You’d have to set the alpha property of each movieclip back to 100, then call fadeOut again :slight_smile: You can set the alphas by a for loop:


btn.onRelease = function(){
for(i=0;i<=amountofboxes;i++){
this["box"+i]._alpha = 100
}
fadeOut(0,5)
}

For example, don’t know if the instance names and paths are correct … I don’t have enough time right now to check.

thanks :slight_smile:

the exact context if anyone else wants to know is:

[AS]
btn.onRelease = function(){
for(i=0;i<=amH*amV-1;i++){
this[“box”+i]._alpha = 100
}
fadeOut(0,5)
}
[/AS]

Yep, you got it :slight_smile:

Ok…so I took your FadeOut function, reversed everything and turned it into FadeIn. My question now is how to make it execute FadeOut once its totally done with FadeIn (ie all the boxes are back in)

Heres all the script:

[AS]
//Declare variables
xspacing = tbBox._width;
yspacing = tbBox._height;
depth = 0;
azcount = 0;
smoothness = 90;
frothness = 10; // for bringing them back in
//Calculate positions and values
amH = Math.ceil(tbHolder._width/tbBox._width);
amV = Math.ceil(tbHolder._height/tbBox._height);
tbT = amVamH-1;
tbBorder._height = tbHolder._height+1;
tbBorder._width = tbHolder._width+1;
tbBorder._x = tbHolder._x-0.5;
tbBorder._y = tbHolder._y-0.5;
//Create grid
for (var k = 0; k<amV; k++) {
for (i=0; i<amH; i++) {
tbBox.duplicateMovieClip(“tbBox”+depth, depth);
cur = this[“tbBox”+depth];
cur._x = tbHolder._x+(xspacing
i);
cur._y = tbHolder._y+(yspacingk);
depth++;
}
}
//
//
// End of grid
//
//
function fadeOut(startboxnr, speed) {
fadeMC(startboxnr, speed);
}
function fadeMC(mcnr, speed) {
azcount++;
this[“tbBox”+mcnr].onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=smoothness) {
this.onEnterFrame = null;
continueFade(this, speed);
mcnr += 1;
fadeOut(mcnr, speed);
}
};
}
function continueFade(mc, speed) {
mc.onEnterFrame = function() {
mc._alpha -= speed;
if (mc._alpha<=0) {
delete mc.onEnterFrame;
}
};
}
// Start of Fade in Function
function fadeIn(startboxnr, speed) {
fadeMCin(startboxnr, speed);
}
function fadeMCin(mcnr, speed) {
azcount–;
this[“tbBox”+mcnr].onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=frothness) {
this.onEnterFrame = null;
continueFadeIn(this, speed);
mcnr -= 1;
fadeIn(mcnr, speed);
}
};
}
function continueFadeIn(mc, speed) {
mc.onEnterFrame = function() {
mc._alpha += speed;
if (mc._alpha>=100) {
delete mc.onEnterFrame;
}
};
}
fadeIn(amH
amV-1, 5);
[/AS]

So basically once you start the movie it fades the squares in. I’d like it to fade them out once its done fading them all in…I’ve tried putting FadeOut(0,5) in various places but all it does is stop the fade in prematurly. I also tried putting in a counter based on i & k but that didn’t work out to good. I even had an
[AS]
if (mcnr <= 0){
fadeOut(0,5);
}
[/AS]

at the bottom of the script and that didn’t help the situation either, I thought I understood what was going on here but I guess not :stuck_out_tongue: