set visibility


#1

hey everyone,

just wondered if anyone could help with some script im stuck on…

Ive got 4 mc?s that overlap, with 4 images in each which are buttons.
1 of the 4 images in each is visible and the other 3 of each set at visibility to false.

On the _root of these mc?s ive got got four buttons, now, what I want to do is on the four buttons on the _root have an action that tells the
Buttons onside the mc to change visibility. For instance…

Click _root button number 3 and mc 1?s number 3 image visibility is set to true, with mc?s 2,3 and 4?s number 3 image set to false.

is that clear enough? anyway, let me know.

thanks

cuse


#2

something to the effect of (on button 1):

on(release) {
_root.mc1._visible = 1;
_root.mc2._visible = 0;
_root.mc3._visible = 0;
_root.mc4._visible = 0;
}

assuming these mc’s are all on the main timeline, should do it.

chris


#3

yea but i want the visibility to be set randomly, so that you click one button and it sets the visibility to one of the three to true and the others to false.

thanks for the response tho.

cuse


#4

My coding skills are a tad out of practice now but something along the lines of :-

on (press) {

do while (i < 3) {
i++;
_root.mc[i]._visible = 0;
}
i=random(3);
_root.mc[i] = 1;
}

something along them lines… had a lunch time :beer: so my brain isn’t functioning properly, you will have to use proper syntax as I don’t think I have…


#5

yea i think you meant:

on (press) {
do {
} while (i < 3);
i++;
_root.mc[i]._visible = “0”;
i = “random(3)”;
_root.mc[i] = “1”;
}

ill give that a fiddle tho :slight_smile:

thanks a lot.

cuse


#6

Originally posted by cuse
[B]yea i think you meant:

on (press) {
do {
i++; [/B]<— this needs to be in the loop
_root.mc[i]._visible = “0”; <-- so does this
} while (i < 3);
i = “random(3)”;
_root.mc[i] = “1”;
<-- this needs the visible attaching, my mistake
[B]}

ill give that a fiddle tho :slight_smile:

thanks a lot.

cuse [/B]


#7

sorry im just too confused now, can you explain that again?

cuse


#8

on (press) {
do {

i++;
_root.mc[i]._visible = “0”;

} while (i < 3);

i = “random(3)”;
_root.mc[i]._visible = “1”;

}

basically what you had corrected from my previous answer was right apart from the “i++ and the visible = 0” needs to be stuck in the loop as this is going to make all the buttons 1 through to 3 invisble, then when the loops finishes it then randomises 1 through to 3 and then makes only 1 button visible…

The only concern I have is the use of the random function, I’m not sure on that syntax at all…

soz too have confused, but good luck…


#9

ahh. no, ive got it now, not sure if that was giving the effect i essentially need but its a good start, ill have to check up on the random function and see what can be put together,

thanks anyway,

cuse


#10

OR

Here’s another way

//note the movieclips must be called “newMovie1”, “newMovie2”, etc …

on(press) {

for(i = 1; i > 4; i++) {
eval(“newMovie”+i)._visiblity = false;
}

num = Math.round(Math.random()*4);
eval(“newMovie”+i)._visiblity = true;

}

Hope that helped :slight_smile:


#11

seems to do nothing, could you explain what its running?

cuse


#12

it has to be _visible = false / true, not _visiblity or _visibility :slight_smile:


#13

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.