PDA

View Full Version : set visibility


cuse
02-20-2003, 06:28 PM
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

fig
02-20-2003, 06:42 PM
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

cuse
02-21-2003, 09:50 AM
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

samartin
02-21-2003, 01:54 PM
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...

cuse
02-21-2003, 02:11 PM
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 :)

thanks a lot.



cuse

samartin
02-21-2003, 02:17 PM
Originally posted by cuse
yea i think you meant:

on (press) {
do {
i++; <--- 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
}

ill give that a fiddle tho :)

thanks a lot.



cuse

cuse
02-21-2003, 02:21 PM
sorry im just too confused now, can you explain that again?



cuse

samartin
02-21-2003, 02:27 PM
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...

cuse
02-21-2003, 02:36 PM
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

chepe297
02-22-2003, 11:45 AM
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 :)

cuse
02-25-2003, 10:05 AM
seems to do nothing, could you explain what its running?



cuse

knebbes
02-25-2003, 11:33 AM
it has to be _visible = false / true, not _visiblity or _visibility :)

CGTalk Moderation
01-14-2006, 12:00 PM
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.