hidden buttons show up randomly after Compile



  • I need some help with a script I'm working on for a mixer. I've put components into Arrays as @Christoph-Hart suggested, which is really simple to show/hide large amounts of controls in one go. And I've created empty arrays to hide these elements when they are not in use.
    In one instance (while a page is already being shown) I need to show/hide components from other arrays that I've setup. This script I have here seems to work, but if I reopen the project preset or hit Compile, elements in a certain array are shown. If I hit compile again, they go away. Same thing happens when I export to VST.
    The array/components in question are in const var Rack = []
    I've created an array called TomEmpty which is indexed at (3). and I use showTom(3); to hide the other elements throughout the script. What looks suspect to you guys?

    Content.makeFrontInterface(1000, 700);
    
    //main fader const var
    const var Image1 = Content.getComponent("Image1");
    const var FaderSelect1 = Content.getComponent("FaderSelect1");
    const var FaderSelect2 = Content.getComponent("FaderSelect2");
    const var FaderSelect3 = Content.getComponent("FaderSelect3");
    const var FaderSelect4 = Content.getComponent("FaderSelect4");
    const var FaderSelect5 = Content.getComponent("FaderSelect5");
    const var FaderSelect6 = Content.getComponent("FaderSelect6");
    const var FaderSelect7 = Content.getComponent("FaderSelect7");
    const var FaderSelect8 = Content.getComponent("FaderSelect8");
    const var Fader1 = Content.getComponent("Fader1");
    const var Fader2 = Content.getComponent("Fader2");
    const var Fader3 = Content.getComponent("Fader3");
    const var Fader4 = Content.getComponent("Fader4");
    const var Fader5 = Content.getComponent("Fader5");
    const var Fader6 = Content.getComponent("Fader6");
    const var Fader7 = Content.getComponent("Fader7");
    const var Fader8 = Content.getComponent("Fader8");
    
    // ch1 small fader
    const var Image2 = Content.getComponent("Image2");
    const var Button1 = Content.getComponent("Button1");
    const var Ch1Aux = Content.getComponent("Ch1Aux");
    const var Ch1Room = Content.getComponent("Ch1Room");
    const var Ch1Oh = Content.getComponent("Ch1Oh");
    const var KickInPan = Content.getComponent("KickInPan");
    const var KickOutPan = Content.getComponent("KickOutPan");
    const var KickSubPan = Content.getComponent("KickSubPan");
    const var KickComPan = Content.getComponent("KickComPan");
    const var KickInSolo = Content.getComponent("KickInSolo");
    const var KickOutSolo = Content.getComponent("KickOutSolo");
    const var KickSubSolo = Content.getComponent("KickSubSolo");
    const var KickComSolo = Content.getComponent("KickComSolo");
    const var KickInCut = Content.getComponent("KickInCut");
    const var KickOutCut = Content.getComponent("KickOutCut");
    const var KickSubCut = Content.getComponent("KickSubCut");
    const var KickComCut = Content.getComponent("KickComCut");
    const var KickInPhase = Content.getComponent("KickInPhase");
    const var KickOutPhase = Content.getComponent("KickOutPhase");
    const var KickSubPhase = Content.getComponent("KickSubPhase");
    const var KickComPhase = Content.getComponent("KickComPhase");
    const var KickSampPhase = Content.getComponent("KickSampPhase");
    const var KickSampIn = Content.getComponent("KickSampIn");
    
    // ch2 small fader
    const var Image3 = Content.getComponent("Image3");
    const var Button2 = Content.getComponent("Button2");
    const var Ch2Aux = Content.getComponent("Ch2Aux");
    const var Ch2Room = Content.getComponent("Ch2Room");
    const var Ch2Oh = Content.getComponent("Ch2Oh");
    const var SnUpPan = Content.getComponent("SnUpPan");
    const var SnDnPan = Content.getComponent("SnDnPan");
    const var SnComPan = Content.getComponent("SnComPan");
    const var SnUpSolo = Content.getComponent("SnUpSolo");
    const var SnDnSolo = Content.getComponent("SnDnSolo");
    const var SnComSolo = Content.getComponent("SnComSolo");
    const var SnUpCut = Content.getComponent("SnUpCut");
    const var SnDnCut = Content.getComponent("SnDnCut");
    const var SnComCut = Content.getComponent("SnComCut");
    const var SnUpPhase = Content.getComponent("SnUpPhase");
    const var SnDnPhase = Content.getComponent("SnDnPhase");
    const var SnComPhase = Content.getComponent("SnComPhase");
    const var SnSampPhase = Content.getComponent("SnSampPhase");
    const var SnSampIn = Content.getComponent("SnSampIn");
    
    // ch3 small fader
    const var Image4 = Content.getComponent("Image4");
    const var Button3 = Content.getComponent("Button3");
    const var Ch3Aux = Content.getComponent("Ch3Aux");
    const var Ch3Room = Content.getComponent("Ch3Room");
    const var Ch3Oh = Content.getComponent("Ch3Oh");
    const var RackUpPan = Content.getComponent("RackUpPan");
    const var RackDnPan = Content.getComponent("RackDnPan");
    const var RackComPan = Content.getComponent("RackComPan");
    const var RackUpSolo = Content.getComponent("RackUpSolo");
    const var RackDnSolo = Content.getComponent("RackDnSolo");
    const var RackComSolo = Content.getComponent("RackComSolo");
    const var RackUpCut = Content.getComponent("RackUpCut");
    const var RackDnCut = Content.getComponent("RackDnCut");
    const var RackComCut = Content.getComponent("RackComCut");
    const var RackUpPhase = Content.getComponent("RackUpPhase");
    const var RackDnPhase = Content.getComponent("RackDnPhase");
    const var RackComPhase = Content.getComponent("RackComPhase");
    const var Fl2ComPhase = Content.getComponent("Fl2ComPhase");
    const var Fl1UpPan = Content.getComponent("Fl1UpPan");
    const var Fl1DnPan = Content.getComponent("Fl1DnPan");
    const var Fl1ComPan = Content.getComponent("Fl1ComPan");
    const var Fl1UpCut = Content.getComponent("Fl1UpCut");
    const var Fl1DnCut = Content.getComponent("Fl1DnCut");
    const var Fl1ComCut = Content.getComponent("Fl1ComCut");
    const var Fl1UpSolo = Content.getComponent("Fl1UpSolo");
    const var Fl1DnSolo = Content.getComponent("Fl1DnSolo");
    const var Fl1ComSolo = Content.getComponent("Fl1ComSolo");
    const var Fl1UpPhase = Content.getComponent("Fl1UpPhase");
    const var Fl1DnPhase = Content.getComponent("Fl1DnPhase");
    const var Fl1ComPhase = Content.getComponent("Fl1ComPhase");
    const var Fl2UpPan = Content.getComponent("Fl2UpPan");
    const var Fl2DnPan = Content.getComponent("Fl2DnPan");
    const var Fl2DComPan = Content.getComponent("Fl2ComPan");
    const var Fl2UpCut = Content.getComponent("Fl2UpCut");
    const var Fl2DnCut = Content.getComponent("Fl2DnCut");
    const var Fl2ComCut = Content.getComponent("Fl2ComCut");
    const var Fl2UpSolo = Content.getComponent("Fl2UpSolo");
    const var Fl2DnSolo = Content.getComponent("Fl2DnSolo");
    const var Fl2ComSolo = Content.getComponent("Fl2ComSolo");
    const var Fl2UpPhase = Content.getComponent("Fl2UpPhase");
    const var Fl2DnPhase = Content.getComponent("Fl2DnPhase");
    
    const var RackSel = Content.getComponent("RackSel");
    const var Fl1Sel = Content.getComponent("Fl1Sel");
    const var Fl2Sel = Content.getComponent("Fl2Sel");
    const var TomSampPhase = Content.getComponent("TomSampPhase");
    const var TomSampIn = Content.getComponent("TomSampIn");
    
    // ch4 small fader
    const var Image5 = Content.getComponent("Image5");
    const var Button4 = Content.getComponent("Button4");
    const var Ch4Aux = Content.getComponent("Ch4Aux");
    const var Ch4Room = Content.getComponent("Ch4Room");
    const var Ch4Oh = Content.getComponent("Ch4Oh");
    const var HatPan = Content.getComponent("HatPan");
    const var Crash1Pan = Content.getComponent("Crash1Pan");
    const var Crash2Pan = Content.getComponent("Crash2Pan");
    const var RidePan = Content.getComponent("RidePan");
    const var HatCut = Content.getComponent("HatCut");
    const var Crash1Cut = Content.getComponent("Crash1Cut");
    const var Crash2Cut = Content.getComponent("Crash2Cut");
    const var RideCut = Content.getComponent("RideCut");
    const var HatSolo = Content.getComponent("HatSolo");
    const var Crash1Solo = Content.getComponent("Crash1Solo");
    const var Crash2Solo = Content.getComponent("Crash2Solo");
    const var RideSolo = Content.getComponent("RideSolo");
    const var HatPhase = Content.getComponent("HatPhase");
    const var Crash1Phase = Content.getComponent("Crash1Phase");
    const var Crash2Phase = Content.getComponent("Crash2Phase");
    const var RidePhase = Content.getComponent("RidePhase");
    
    // Save the controls into arrays
    
    const var empty = []
    
    const var Ch1SmFader = [Content.getComponent("Image2"),
                            Content.getComponent("Ch1Aux"),
                            Content.getComponent("Ch1Room"),
                            Content.getComponent("Ch1Oh"),
                            Content.getComponent("KickInPan"),
                            Content.getComponent("KickOutPan"),
                            Content.getComponent("KickSubPan"),
                            Content.getComponent("KickComPan"),
                            Content.getComponent("KickInSolo"),
                            Content.getComponent("KickOutSolo"),
                            Content.getComponent("KickSubSolo"),
                            Content.getComponent("KickComSolo"),
                            Content.getComponent("KickInCut"),
                            Content.getComponent("KickOutCut"),
                            Content.getComponent("KickSubCut"),
                            Content.getComponent("KickComCut"),
                            Content.getComponent("KickInPhase"),
                            Content.getComponent("KickOutPhase"),
                            Content.getComponent("KickSubPhase"),
                            Content.getComponent("KickComPhase"),
                            Content.getComponent("KickSampPhase"),
                            Content.getComponent("KickSampIn"),
                            Content.getComponent("Button1")];
                            
    const var Ch2SmFader = [Content.getComponent("Image3"),
                            Content.getComponent("Ch2Aux"),
                            Content.getComponent("Ch2Room"),
                            Content.getComponent("Ch2Oh"),
                            Content.getComponent("SnUpPan"),
                            Content.getComponent("SnDnPan"),
                            Content.getComponent("SnComPan"),
                            Content.getComponent("SnUpSolo"),
                            Content.getComponent("SnDnSolo"),
                            Content.getComponent("SnComSolo"),
                            Content.getComponent("SnUpCut"),
                            Content.getComponent("SnDnCut"),
                            Content.getComponent("SnComCut"),
                            Content.getComponent("SnUpPhase"),
                            Content.getComponent("SnDnPhase"),
                            Content.getComponent("SnComPhase"),
                            Content.getComponent("SnSampPhase"),
                            Content.getComponent("SnSampIn"),
                            Content.getComponent("Button2")];
                            
    const var Ch3SmFader = [Content.getComponent("Image4"),
                            Content.getComponent("Ch3Aux"),
                            Content.getComponent("Ch3Room"),
                            Content.getComponent("Ch3Oh"),
                            Content.getComponent("RackSel"),
                            Content.getComponent("Fl1Sel"),
                            Content.getComponent("Fl2Sel"),
                            Content.getComponent("TomSampPhase"),
                            Content.getComponent("TomSampIn"),
                            Content.getComponent("Button3")];
                            
    const var Ch4SmFader = [Content.getComponent("Image5"),
                            Content.getComponent("Ch4Aux"),
                            Content.getComponent("Ch4Room"),
                            Content.getComponent("Ch4Oh"),
                            Content.getComponent("HatPan"),
                            Content.getComponent("Crash1Pan"),
                            Content.getComponent("Crash2Pan"),
                            Content.getComponent("RidePan"),
                            Content.getComponent("HatCut"),
                            Content.getComponent("Crash1Cut"),
                            Content.getComponent("Crash2Cut"),
                            Content.getComponent("RideCut"),
                            Content.getComponent("HatSolo"),
                            Content.getComponent("Crash1Solo"),
                            Content.getComponent("Crash2Solo"),
                            Content.getComponent("RideSolo"),
                            Content.getComponent("HatPhase"),
                            Content.getComponent("Crash1Phase"),
                            Content.getComponent("Crash2Phase"),
                            Content.getComponent("RidePhase"),
                            Content.getComponent("Button4")];
                            
    const var Ch5SmFader = []
    
    
                            
                            
    // page index
    inline function showPage(pageIndex)
    {
        for(k in empty) 
        {
            k.showControl(pageIndex == 0);
        }
        
        for(k in Ch1SmFader) 
        {
        
            k.showControl(pageIndex == 1);
        }
        
        for(k in Ch2SmFader) 
        {
            k.showControl(pageIndex == 2);
        } 
        
        for(k in Ch3SmFader) 
        {
            k.showControl(pageIndex == 3);
        }
        
        for(k in Ch4SmFader) 
        {
            k.showControl(pageIndex == 4);
        }
        
        for(k in Ch5SmFader) 
        {
            k.showControl(pageIndex == 5);
        }
    
    }
    
    const var Rack = [                        
                        Content.getComponent("RackUpPan"),
                        Content.getComponent("RackDnPan"),
                        Content.getComponent("RackComPan"),
                        Content.getComponent("RackUpSolo"),
                        Content.getComponent("RackDnSolo"),
                        Content.getComponent("RackComSolo"),
                        Content.getComponent("RackUpCut"),
                        Content.getComponent("RackDnCut"),
                        Content.getComponent("RackComCut"),
                        Content.getComponent("RackUpPhase"),
                        Content.getComponent("RackDnPhase"),
                        Content.getComponent("RackComPhase")];
                        
    const var Floor1 = [
                        Content.getComponent("Fl1UpPan"),
                        Content.getComponent("Fl1DnPan"),
                        Content.getComponent("Fl1ComPan"),
                        Content.getComponent("Fl1UpSolo"),
                        Content.getComponent("Fl1DnSolo"),
                        Content.getComponent("Fl1ComSolo"),
                        Content.getComponent("Fl1UpCut"),
                        Content.getComponent("Fl1DnCut"),
                        Content.getComponent("Fl1ComCut"),
                        Content.getComponent("Fl1UpPhase"),
                        Content.getComponent("Fl1DnPhase"),
                        Content.getComponent("Fl1ComPhase")];
    
    const var Floor2 = [
                        Content.getComponent("Fl2UpPan"),
                        Content.getComponent("Fl2DnPan"),
                        Content.getComponent("Fl2ComPan"),
                        Content.getComponent("Fl2UpSolo"),
                        Content.getComponent("Fl2DnSolo"),
                        Content.getComponent("Fl2ComSolo"),
                        Content.getComponent("Fl2UpCut"),
                        Content.getComponent("Fl2DnCut"),
                        Content.getComponent("Fl2ComCut"),
                        Content.getComponent("Fl2UpPhase"),
                        Content.getComponent("Fl2DnPhase"),
                        Content.getComponent("Fl2ComPhase")];
    
    const var TomEmpty = []
    
    // Tom page index
    inline function showTom(pageIndex)
    {
        for(k in Rack) 
        {
            k.showControl(pageIndex == 0);
        }
        
        for(k in Floor1) 
        {
        
            k.showControl(pageIndex == 1);
        }
        
        for(k in Floor2) 
        {
            k.showControl(pageIndex == 2);
        }
        
        for(k in TomEmpty) 
        {
            k.showControl(pageIndex == 3);
        }
        
    }
    
    
    inline function onFaderSelect1Control(component, value)
    {
        Button1.setValue(0);
        showTom(3);
        FaderSelect2.setValue(0);
        FaderSelect3.setValue(0);
        FaderSelect4.setValue(0);
        FaderSelect5.setValue(0);
        FaderSelect6.setValue(0);
        FaderSelect7.setValue(0);
        FaderSelect8.setValue(0);
        
        if(value)
    	    showPage(1);
    	else if(1-value)
    	    showPage(0);
    };
    
    Content.getComponent("FaderSelect1").setControlCallback(onFaderSelect1Control);
    
    inline function onButton1Control(component, value)
    {
        FaderSelect1.setValue(0);
        if(value)
    	    showPage(0);
    };
    
    Content.getComponent("Button1").setControlCallback(onButton1Control);
    
    inline function onFaderSelect2Control(component, value)
    {
        Button2.setValue(0);
        showTom(3);
        FaderSelect1.setValue(0);
        FaderSelect3.setValue(0);
        FaderSelect4.setValue(0);
        FaderSelect5.setValue(0);
        FaderSelect6.setValue(0);
        FaderSelect7.setValue(0);
        FaderSelect8.setValue(0);
        if(value)
    	    showPage(2);
    	else if(1-value)
    	    showPage(0);
    };
    
    Content.getComponent("FaderSelect2").setControlCallback(onFaderSelect2Control);
    
    inline function onButton2Control(component, value)
    {
        FaderSelect2.setValue(0);
        if(value)
    	    showPage(0);
    };
    
    Content.getComponent("Button2").setControlCallback(onButton2Control);
    
    inline function onFaderSelect3Control(component, value)
    {
        Button3.setValue(0);
        Fl1Sel.setValue(0);
        Fl2Sel.setValue(0);
        FaderSelect1.setValue(0);
        FaderSelect2.setValue(0);
        FaderSelect4.setValue(0);
        FaderSelect5.setValue(0);
        FaderSelect6.setValue(0);
        FaderSelect7.setValue(0);
        FaderSelect8.setValue(0);
        if(value)
    	   { 
    	       RackSel.setValue(1);
    	       showPage(3);
    	       showTom(0);
    	   }
    	else if(1-value)
    	    {
    	      showPage(0);
    	      showTom(3);
    	    }
    
    };
    
    Content.getComponent("FaderSelect3").setControlCallback(onFaderSelect3Control);
    
    
    inline function onRackSelControl(component, value)
    {
    	Fl1Sel.setValue(0);
    	Fl2Sel.setValue(0);
    	if(value)
        {
            showTom(0);
        }
    };
    
    Content.getComponent("RackSel").setControlCallback(onRackSelControl);
    
    inline function onFl1SelControl(component, value)
    {
    	RackSel.setValue(0);
    	Fl2Sel.setValue(0);
    	if(value)
        {
            showTom(1);
        }
    };
    
    Content.getComponent("Fl1Sel").setControlCallback(onFl1SelControl);
    
    
    inline function onFl2SelControl(component, value)
    {
    	RackSel.setValue(0);
    	Fl1Sel.setValue(0);
    	if(value)
        {
            showTom(2);
        }
    };
    
    Content.getComponent("Fl2Sel").setControlCallback(onFl2SelControl);
    
    inline function onButton3Control(component, value)
    {
        FaderSelect3.setValue(0);
        if(value)
    	    showPage(0);
    	    showTom(3);
    	    
    };
    
    Content.getComponent("Button3").setControlCallback(onButton3Control);
    
    inline function onFaderSelect4Control(component, value)
    {
        Button4.setValue(0);
        showTom(3);
        FaderSelect1.setValue(0);
        FaderSelect2.setValue(0);
        FaderSelect3.setValue(0);
        FaderSelect5.setValue(0);
        FaderSelect6.setValue(0);
        FaderSelect7.setValue(0);
        FaderSelect8.setValue(0);
        if(value)
    	    showPage(4);
    	else if(1-value)
    	    showPage(0);
    };
    
    Content.getComponent("FaderSelect4").setControlCallback(onFaderSelect4Control);
    
    inline function onButton4Control(component, value)
    {
        FaderSelect4.setValue(0);
        if(value)
    	    showPage(0);
    };
    
    Content.getComponent("Button4").setControlCallback(onButton4Control);
    
    inline function onFaderSelect5Control(component, value)
    {
        Button1.setValue(0);
        showTom(3);
        FaderSelect1.setValue(0);
        FaderSelect2.setValue(0);
        FaderSelect3.setValue(0);
        FaderSelect4.setValue(0);
        FaderSelect6.setValue(0);
        FaderSelect7.setValue(0);
        FaderSelect8.setValue(0);
        if(value)
    	    showPage(5);
    	else if(1-value)
    	    showPage(0);
    };
    
    Content.getComponent("FaderSelect5").setControlCallback(onFaderSelect5Control);
    

  • administrators

    Just call showPage(0); in the onInit callback to make sure it's initialised correctly.



  • @christoph-hart This didn't seem to work for this situation.
    I was setting RackSel.setValue(1) on one of my callbacks...

        if(value)
    	   { 
    	       RackSel.setValue(1);
    	       showPage(3);
    	       showTom(0);
    	   }
    	else if(1-value)
    	    {
    	      showPage(0);
    	      showTom(3);
    	    }
    

    so adding RackSel.setValue(0); to my else if statement fix it!

        if(value)
    	   { 
    	       RackSel.setValue(1);
    	       showPage(3);
    	       showTom(0);
    	   }
    	else if(1-value)
    	    {
    	      showPage(0);
    	      showTom(3);
                  RackSel.setValue(0);
    	    }
    

Log in to reply
 

2
Online

282
Users

767
Topics

5.0k
Posts

Looks like your connection to Forum was lost, please wait while we try to reconnect.