mardi 24 janvier 2017

Flash AS3 enable/disable buttons from inside movie clip (MC is linked to scrollpane)

I have scene1 within that scene1, i have "Next" button and i have scroll pane which is linked to MC1 with bunch of form fields. so i am trying to enable / disable buttons from the MC1. since the buttons on scene1 stage, am trying to validate my form fields then enable button. but when i test it, says undefied property.. here is the code which is included in MC1 inside.

// Step 4 Validation start here (these buttons on scene1 stage)

bttnNext4.visible = false; bttnNext4_disabled.enabled = false; 


//Next button
bttnNext4.addEventListener(MouseEvent.CLICK, step4tostep5);

function step4tostep5(event: MouseEvent): void {
    if (validateForm3()) {
        gotoAndStop(20);
    }
}
// Validation
function validateForm3(): Boolean {
    return name_step4.text != "" && validate_step4();
}

//event
name_step4.addEventListener(Event.CHANGE, ChangeEvent3);
combosmall_step4.addEventListener(Event.CHANGE, ChangeEvent3);
combosmall2_step4.addEventListener(Event.CHANGE, ChangeEvent3);
combosmall3_step4.addEventListener(Event.CHANGE, ChangeEvent3);
txtsmall_step4.addEventListener(Event.CHANGE, ChangeEvent3);
txtsmall2_step4.addEventListener(Event.CHANGE, ChangeEvent3);
txtsmall3_step4.addEventListener(Event.CHANGE, ChangeEvent3);

function ChangeEvent3(event: Event): void {

    var enabled = name_step4.text != "" &&  validate_step4();
    bttnNext4.visible = enabled; 
     bttnNext4_disabled.visible = !enabled;
}
function validate_step4(){
    var enabled = false;
    if(combosmall_step4.selectedIndex > 0 || combosmall2_step4.selectedIndex > 0 || combosmall3_step4.selectedIndex > 0)
        enabled = true;
    if(combosmall_step4.selectedIndex == 0 ){
        enabled = txtsmall_step4.text != "";
    }
    if(combosmall2_step4.selectedIndex == 0){
        enabled = enabled && txtsmall2_step4.text != "";
    }
    if(combosmall3_step4.selectedIndex == 0){
        enabled = enabled && txtsmall3_step4.text != "";
    }
    return enabled;
}



//combo box selection

combosmall_step4.addEventListener("change", ComboChangeEvent5);
combosmall_step4.dispatchEvent(new Event("change", true));
function ComboChangeEvent5(event: Event): void {
    if (combosmall_step4.selectedIndex == 1 ||  combosmall_step4.selectedIndex ==2  ) {
         txtsmall_step4.visible=false;

    }
    else
    {
        txtsmall_step4.visible=true;

    }
}

combosmall2_step4.addEventListener("change", ComboChangeEvent5A);
combosmall2_step4.dispatchEvent(new Event("change", true));
function ComboChangeEvent5A(event: Event): void {
    if (combosmall2_step4.selectedIndex == 1 ||  combosmall2_step4.selectedIndex ==2  ) {
         txtsmall2_step4.visible=false;
        GB1_step4.visible = false;
    }
    else
    {
        txtsmall2_step4.visible=true;
        GB1_step4.visible = true;
    }
}

combosmall3_step4.addEventListener("change", ComboChangeEvent5B);
combosmall3_step4.dispatchEvent(new Event("change", true));
function ComboChangeEvent5B(event: Event): void {
    if (combosmall3_step4.selectedIndex == 1 ||  combosmall3_step4.selectedIndex ==2  ) {
         txtsmall3_step4.visible=false;
        GB2_step4.visible = false;
    }
    else
    {
        txtsmall3_step4.visible=true;
        GB2_step4.visible = true;
    }
}

Aucun commentaire:

Enregistrer un commentaire