Mx - grid effect with alpha fade

I have the code below positioned on a keyframe in the main time line which gives me a grid effect using the instance ‘cube’ of the MC 'cube.

gridy=30;
gridx=30;
num=0;

for (var i=0;i < 10;i++)
{
for (var j=0;j < 10;j++)
{
cube.duplicateMovieClip(“cube”+num, num);
mc=this[“cube”+num];
mc._x=gridxi;
mc._y=gridy
j;
num++;

}
}
cube._visible=0;

Then i have the code below positioned within the MC to give me an alpha effect:

onClipEvent (load) {
_alpha = 100;
}
onClipEvent (enterFrame) {
if (_alpha > 0) {
_alpha–;
}
}

The effect i want though is for the reduction in alpha to stagger from instance to instance, whereas at the moment they all fade together.
Is there a way of tweeking the code i already have to achieve this staggering effect or does the whole thing need re thinking.

any help/thoughts would be appreciated

cheers

gridy=30;
gridx=30;
num=0;

for (var i=0;i < 10;i++)
{
for (var j=0;j < 10;j++)
{
cube.duplicateMovieClip(“cube”+num, num);
mc=this[“cube”+num];
mc._x=gridxi;
mc._y=gridy
j;
num++;
cube.angle = i*.1+j*.1; // from one corner to the other.
cube.onEnterFrame = alphaEffect;
}
}

function alphaEffect() {
this._alpha = Math.sin(this.angle += .1)*50+50;
}

Ok, i havent checked to see if that will acutally work, but it looks about right to me. Just put that in a frame on the root timeline and have a MC in your library with an ID ‘cube’. I know you knew that last bit anyway :slight_smile: .

Let me know if it works,
Regards,
Viru.

P.S look at the information section in Site 1 to see something similar.

Thanks for your help but it doesn’t seem to work: can anyone see the problem?

gridy=30;
gridx=30;
num=0;

for (var i=0;i < 10;i++)
{
for (var j=0;j < 10;j++)
{
cube.duplicateMovieClip(“cube”+num, num);
mc=this[“cube”+num];
mc._x=gridxi;
mc._y=gridy
j;
num++;
cube.angle = i*.1+j*.1; // from one corner to the other.
cube.onEnterFrame = alphaEffect;
}
}

function alphaEffect() {
this._alpha = Math.sin(this.angle += .1)*50+50;
}
cube._visible=0;

Stick around for 20mins and i’ll make you a fla.

Viru.

Do you want each cube to change individually?

V.

I’m using attachMovie instead of duplicateMovie now, did you have an instance of cube on the stage when you tried?

Check out my actionscript below. Put that in a frame on the main timeline. And in your library create a cube shape with dimensions 20x20. Then in the Linkage settings give it the ID of cube.

[AS]
gridy = 30;
gridx = 30;
num = 0;

for (i=0; i<8; i++) {
for(j=0; j<8; j++) {
c = attachMovie(“cube”, “cube”+num, num);
c._x = 50+(i25);
c._y = 25+(j
25);

	c.angle = i*-.1 + j*.1;
	c.onEnterFrame = alphaEffect;
	num++;
}

}

function alphaEffect() {
this._alpha = Math.sin(this.angle += .1)*50+50;
}
[/AS]

Then publish and enjoy.

Regards,
Viru.

your a star…

must admit i know little about this ‘linkage’ area of creating a new symbol - i’ll have to do some reading up on it.

presumably to create the effect just the once and then stop it i’d just put a stop action at the end of the code?

Nope, that wont work becuase of the ‘c.onEnterFrame’ part of the code. This makes each cube continuously call and execute the alphaEffect method.

I’ve never actually thought about making it only loop round once, I’ll try and do that now, or in a minute.

But placing a stop(); at the end only means ‘Stop the movie from going onto the next frame in the timeline’.

Regards,
Viru.

Thanks to Viru this script works a treat. The next step is to get it to just loop once and then stop, alas thats were my AS comes unstuck. If you can come up with a solution Viru that would be great in that it would feel like its come full circle.

but it is open to the floor.

gridy = 30;
gridx = 30;
num = 0;

for (i=0; i<8; i++) {
for(j=0; j<8; j++) {
c = attachMovie(“cube”, “cube”+num, num);
c._x = 50+(i25);
c._y = 25+(j
25);

            c.angle = i*-.1 + j*.1;
            c.onEnterFrame = alphaEffect;
            num++;
			
    }

}

function alphaEffect() {
this._alpha = Math.sin(this.angle += 0.1)*50+50;
}

anybody any thoughts???

First of all, please use the actionscript tags, it makes code easier to read :slight_smile:
So, if I understand correctly what you’re trying to do, 1 full circle is 360°, that is to say 2*PI radians, so if you try this:

gridy = 30;
gridx = 30;
num = 0;

for (i=0; i<8; i++) {
        for(j=0; j<8; j++) {
                c = attachMovie("cube", "cube"+num, num);
                c._x = 50+(i*25);
                c._y = 25+(j*25);
                
                c.angle = i*-.1 + j*.1;
                c.onEnterFrame = alphaEffect;
                num++;
				
        }
}

function alphaEffect() {
        if ( this.angle < 2*Math.PI ) this._alpha = Math.sin(this.angle += 0.1)*50+50;
else delete this.onEnterFrame ;
} 

Thank you for that Ilyas

and your comments are duely noted.

wilma