-
Switch (this) - Case (that)... some help. :)
I came up with this code while trying some obvious ones,
to make all buttons disappear when one of them is clicked,
and at the same time, one other of each appear.
Home1.onPress = function(){
Home1._visible = false;
Home2._visible = true;
Home2.play()
switch (Empresa2._visible = false) {
case condition : Empresa2._visible = true
}
switch (Clientes2._visible = false) {
case condition : Clientes2._visible = true
}
switch (Forne2._visible = false) {
case condition : Forne2._visible = true
}
}
Now i would like to know if there is a away to put all those
- ._visible = false - conditions, in one "switch" sentence, then all those
- _visible = true - conditions in one "case".
Is there a possibility? or i am dreaming.
-
the switch statement is useful for situations where you have an excessive number of possibilities, but a limited circumstance - i use it with keycodes in html form navigation for example
Code:
function nav() {
switch(event.keyCode) {
case 13 : someElement.focus(); break;
case 37 : someOtherElement.focus(); break;
case 38 : someOtherElement.focus(); break;
case 39 : someOtherElement.focus(); break;
case 40 : someOtherElement.focus(); break;
case 8 : if(event.srcElement.tagName!=='input') return false; break;
case 32 : event.srcElement.focus(); event.srcElement.select(); break;
}}
other than that, it's not terribly useful. assuming you're just toggling visibility, its a relatively simple matter of using an array and a loop, maybe like this
Code:
A = [Empresa2,Clientes2,Forne2];
Home1.onPress=function(){
for (var i in A) if(A[i].visible) A[i].visible = false; else A[i].visible = true;
}
-
Thanx for the help, one more thing, is possible for a movieclip to
unload it self?
This is a bar with 5 or 6 buttons, after one of them alone is clicked they
will get invisible then a movieclip will appear at the same place, but will
be a short period of time, just about 75 frames, then it is supose to get
invisible for the button to appear, is that possible?
I thought that would work with some kind of timer, or some code that would
read the movieclip and order it to get invisible when reach the 75 frames,
something like that. Any help would be great.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|