all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

A smarter way...


A smarter way... thejokerman05
2/2/2006 9:32:27 PM
flash actionscript:
I have these instances that I would like to change now and then. The problem is
that it is very time consuming to write like this, and wonder if there's an
easier way?




undermeny1.alphaTo (100);
undermeny2.slideTo ("",50);
undermeny2.alphaTo (0);
undermeny3.slideTo ("",50);
undermeny3.alphaTo (0);
undermeny4.slideTo ("",50);
undermeny4.alphaTo (0);
Re: A smarter way... adrianTNT
2/2/2006 9:51:27 PM
I am not 100% positive but try this:

undermeny1.alphaTo(100);
for (i=2; 1<=4; i++) {
tellTarget ("undermeny"+i) {
slideTo("", 50);
alphaTo(0);
}
}

I laced undermeny1 separately because I saw it was the only one written
different in your code.
Try the above block. If it doesn't work there are other ways.
Re: A smarter way... Rothrock
2/2/2006 10:06:13 PM
tellTarget is a bit old school and may well work. There are some tricks and
things to watchout for, but I'm not totally versed in using it ? I haven't used
it in years.

I think the most popular way would be to use the array notation. So for
example if all your undermeny clips were on the same timeline as the lines of
code you could do something like:

for(i=2;i<=4;i++){
this.slideTo("",50);
this.alphaTo(0);
}

This code tells flash to look inside the current object (called this) and find
the object with the name given between the square brackets. Notice here that it
is a combination of a set piece of text and a variable. But it could be
completely text or completely a variable.

This kind of notation can be used in a lot of ways and is very useful for
manipulating many things on the stage. Generally you need to conform the names
of your clips to a nice ordered sequence, but you could also put just regular
names into an array and then pull them out as well.

myArray=new Array("Movie1","frog_mc","ThisIsit10");
for(i=0;i<myArray.length;i++){
this]._visible=0;
}

Have fun.
Re: A smarter way... Rothrock
2/2/2006 10:07:01 PM
D'oh I forgot that i inside square brackets makes the forums go to italic.

Re: A smarter way... thejokerman05
2/2/2006 10:33:37 PM
AddThis Social Bookmark Button