5 Replies Latest reply on Mar 29, 2011 2:41 PM by Flex harUI

    Flex warning: variable has no type declaration

    Johnking08 Level 1

      I need to  dynamically create several Form or Panel, called MyForm1, MyForm2, MyPanel1, MyPanel2, ... They are different because of the children in the Form or Panel. I also added some addtional public methods (method1, method2 ...) to the <mx:Form> or <mx:Panel>.


      I have a function, called myFactory,  that returns the MyForm1, MyPanel1... for me according to the input parameters. It is defined something like:


      function myFactory(input:String):DisplayObject {





      I tried two ways to call myFactory.



      var myViewObj:DisplayObject = myFactory(input:String); // no error. no warning.


      myViewObj.method1(); // compilation error because DisplayObject dose not have method1



      var myViewObj = myFactory(input:String); // no error, but got warning: variable has no type declaration


      myViewObj.method1(); // it works fine.


      It looks like the type of myViewObj is the actual type of myFactory retures, which could be one of MyForm1, MyPanel1....


      My questions are

      1. Is there a way I can declara a type to myViewObj to get ride of  warning.

      2. what type myViewObj should be called? generic type?