1
votes

i have a program in flex wherein i check if a particular field is validated then the submit button is enabled. I am trying something like this:

public function init():void
    {
        submit.addEventListener(Event.CHANGE,enableSubmit);
    }

    public function enableSubmit(event:TextInput):void
    {
     //some code to enable the button
    }

I can call init in creation complete to add event listener to submit! is this the correct way to do it ? Please help!

1

1 Answers

0
votes

Yes, you can call the init in the creationComplete. The only thing you need to change in your code is the parameter of the enableSubmit from TextInput to Event because the event is passed by parameter, like the code below:

public function enableSubmit(event:Event):void
{
//some code to enable the button    
}

Also the event listener need to be added to the TextInput, so I am assuming that submit control is the TextInput submit.addEventListener(Event.CHANGE,enableSubmit);