1 Reply Latest reply on Aug 29, 2007 8:43 AM by peterent

    Preventing default behavior in a viewstack?

    Handycam Level 1
      I've got a component with a handler like:

      public function choiceHandler():void {
      if (everythingOK) { processData(); }
      else { showAlert(_msg5,_ttl5); }
      }

      I'm calling this handler from the viewStack, using the "hide" event for this component's instance since I want it handled when the user leaves the screen.

      However, if the alert fires (the "else" clause) the viewstack has already gone to another child.

      How can I "catch" that error and not have the viewstack leave that page? Or is there a better way to do this?
        • 1. Re: Preventing default behavior in a viewstack?
          peterent Level 2
          I'm not sure if this will work, but include an event argument in your choiceHandler and if the else clause executes, then do event.preventDefault() which *may* tell the ViewStack not to switch children.

          Otherwise you may need to extend the ViewStack and check the docs to see what protected functions it has that you can override and alter its behavior.