1 Reply Latest reply on Apr 13, 2007 11:43 AM by ntsiii

    VERY weird bug

      on my stage, i've got a viewstack and two canvases to it.

      on canvas 2 is txtQuestion.

      when i reference txtQuestion like so

      if(quizQuestions.length >= currentQ) {
      Alert.show(txtQuestion.toString());
      txtQuestion.text = quizQuestions[currentQ];
      } else {
      txtQuestion.text = '';
      }

      It errs.

      When i try/catch.

      it errs.

      when i try to Alert.show(txtQuestion.toString());

      it errs.

      what on earth am i doing wrong?

      Oh an of course, in the exact same function, set other values involving [currentQ] so i know thats not the issue.

      I also assign text values to other elements on that same canvas to values. so i know its not that either.

      its almost like its txtQuestion is not being initalized properly.

      Also to note...yes the element exists and i haven't misspelt it. Flex builder is even acknowledging its existance when i type txtQuestion.
        • 1. Re: VERY weird bug
          ntsiii Level 3
          Viewstack and the other navigator containers use "deferred instantiation" by default. This allows an application to load faster at startup by only instantiating the visible elements. So txtQuestion does not exist until a user navigates to that view.

          The quick fix is to set creationPolicy="all" on the ViewStack. This is not good practice, though. The correct solution is to architect the app using binding or your own events to handle the data availability.

          Tracy