2 Replies Latest reply on Sep 12, 2007 4:43 PM by bijayrungta

    Assigning an instance of an object of a subclass of the class which was the declared type of the variable being assigned

    bijayrungta
      Is some thing like the following not valid in Action Script

      package myPackage
      {
      public class myClass
      {
      public function myFunction(xQuestion:XML):void
      {
      var oQuestion:Question;// notice this
      // or var oQuestion;

      if (xQuestion.name() == "QUESTION_MULTIPLECHOICE") {
      oQuestion:QuestionMultipleChoice = new QuestionMultipleChoice();// assigning a value to it
      } else if (xQuestion.name() == "QUESTION_MULTIPLEANSWER") {
      oQuestion:QuestionMultipleAnswer = new QuestionMultipleAnswer();
      }
      }//eND OF FUNCTION
      }//End of class
      }//end of package


      That is declaring a variable
      QuestionMultipleChoice, and are inherited from Question

      It shows an error saying

      1067: Implicit coercion of a value of type assessmentbuilder:QuestionMultipleChoice to an unrelated type Class.