4 Replies Latest reply on Mar 7, 2009 10:58 PM by RUSH-ME

    UIcomponent initiaze method

    waterturtle
      I am new to Flex and i am stuck with this problem. The attached file is part of a big application, which compiled to swf file without any problem. It also works sometimes, but sometimes "chart" object which is UIComponent is not initialized and i got Alert ("not initialized" ).
      My question, is how can i wait ( loop or something like this ) till "chart" will initialize?
      If i call chart.initialize() - i got an error, so i probably do something wrong.

      To summarize : i want to check if "chart" initialized, if not - i want initialize it and then procceed to "addData" method

      Thanks,
      John.

      This is my App.xml file :

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      xmlns:somePackage="com.me.*"
      backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#DDDDDD, #FFFFFF]"
      applicationComplete="init()" styleName="all" frameRate="40" >
      <mx:Script>
      <![CDATA[
      protected function init ():void
      // some stuff here
      {
      if (chart.initialized){
      addData("init" );
      } else {
      Alert.show("not initialized");
      }
      }
      public function addData(temp:String):void
      {
      chart.addNewData(temp);
      }
      ]]>
      </mx:Script>
      <somePackage:SEChart id="chart" x="10" y="10" width="98%" />
      </mx:Application>