私はこのコンセプトが実行可能かどうか疑問に思っていました。
シナリオ:
非常に似ている1つのステージ上の4つの領域(例えば、ウェブカメラ会議、各領域は同じ機能を有する)
ボタンオブジェクトには番号が付けられます(たとえば、エリア1には再生ボタン1、ミュートボタン1、ネームボタン1、ネームラベル1などがあります)
すべての領域に閉じる/閉じるボタンを表示します(close1、close2、close3 ...)。
私は以下をアーカイブしたい:
if(close1.isPressed){
function invisall(1);
}
/*
* instead of writing
* if(close1.isPressed){
* playbutton1._visible=false;
* mutebutton1._visible=false;
* }else if(close2.isPressed){
* playbutton2._visible=false;
* mutebutton2._visible=false;
* etc. resulting in an enormous block.
* the interesting part. buttonNr gets added via String to become a real buttonname(eg
* playbutton1 as mentioned above).*/
function invisall(int buttonNr){
String newPlayButtonObjectName="playbutton"+buttonNr;
newPlayButtonObjectName._visible=false;
String newMuteButton="mutebutton"+buttonNr;
newMuteButton._visible=false;
}
this should do the trick via dynamic Nr at the end of each default button(eg
playbutton)
but ofc
"playbutton1"._visible=false;
doesnt work because playbutton1 is still a String.
how can i take the String as a Buttonname/ButtonObject?
do i need to write an new function? this would destroy the purpose of less code.
多分、この考え方が好きかもしれません。今のところ私はステージ上に置くフレームに領域を分割します。それは助けるべきである。
乾杯