5 Replies Latest reply: Apr 16, 2012 7:47 AM by Z4g0s RSS

    Strange error that occurs randomly...

    Z4g0s Community Member

      HI,

       

      I'm using flash builder and I have a strange error, this error occurs randomly and in order to fix it I do the following:

       

      1) Remove the line where the error is

      2) Save the file (so the workspace is rebuild), the problem is gone

      3) Paste the line removed

      4) Save again and there is no problem

       

      Here's a piece of code:

       

      protected function comboHandler(event:ComboEvent):void
      {
                u.profilo = Profilo(event.picked);
      }
      

       

      The ComboEvent picked is of type Object

      The u is referring to a class where there is a getter and setter

       

       

      public function get profilo():Profilo
      {
                return profilo_value;
      }
        
      public function set profilo(i:Profilo):void
      {
                profilo_value = i;
      }
      

       

      The error I get from Flash Builder is

      1118: Implicit coercion of a value with static type listClass:Profilo to a possibly unrelated type listClass:Profilo.

       

      Why do I get this error?

      Is it related to flash builder?

        • 1. Re: Strange error that occurs randomly...
          Z4g0s Community Member

          no one?

          • 2. Re: Strange error that occurs randomly...
            Bharat Patel Community Member

            It would be great if you share code snippets of the Profilo class?

            • 3. Re: Strange error that occurs randomly...
              Z4g0s Community Member

              Here's the full Profilo Class

               

              package testClass
              {
                import mx.collections.ArrayList;
              
              
                public class Profilo
                {
                public var COD_CLIENTE:String = "";
                [Bindable]public var COD_PROFILO:String = "";
                public var DESC_PROFILO:String = "";
                public var selected:Boolean = false;
                private var FUNZIONI:ArrayList = new ArrayList();
              
                public function Profilo()
                {
              
                }
              
                public function getFunzione(i:int):String
                {
                      var t:ProfiloFunzioni = ProfiloFunzioni(FUNZIONI.getItemAt(i));
                      return t.COD_FUNZIONE;
                 }
              
              
                public function get funzioniCount():int
                {
                return FUNZIONI.length;
                }
              
                }
              }
              
              • 4. Re: Strange error that occurs randomly...
                Bharat Patel Community Member

                Its gives error in this line :

                 

                u.profilo = Profilo(event.picked);

                 

                Its error related to type conversion. Refer the following example:

                 

                Application file:

                <?xml version="1.0" encoding="utf-8"?>

                <!-- http://bharatria.wordpress.com/ -->

                <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                                                 xmlns:s="library://ns.adobe.com/flex/spark"

                                                 xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

                          <fx:Script>

                                    <![CDATA[

                                              import spark.events.IndexChangeEvent;

                 

                                              import testClass.Profilo;

                 

                 

                                              protected function cb_changeHandler(event:IndexChangeEvent):void

                                              {

                                                             // TODO Auto-generated method stub

                                                             var classRef:Profilo = new Profilo();

                                                             classRef.profilo = String(cb.selectedItem);

                                              }

                 

                 

                                    ]]>

                          </fx:Script>

                 

                          <s:ComboBox id="cb"

                                                        change="cb_changeHandler(event)">

                                    <s:ArrayList>

                                              <fx:String>Flash</fx:String>

                                              <fx:String>Flex</fx:String>

                                              <fx:String>Dreamweaver</fx:String>

                                              <fx:String>Photoshop</fx:String>

                                    </s:ArrayList>

                          </s:ComboBox>

                 

                 

                </s:Application>

                 

                 

                Profilo Class :

                package testClass

                {

                          import mx.collections.ArrayList;

                 

                          public class Profilo

                          {

                                    public var profilo_value:String = "";

                 

                                    public function get profilo():String

                                    {

                                              return profilo_value;

                                    }

                 

                                    public function set profilo(i:String):void

                                    {

                                              profilo_value = i;

                                    }

                          }

                }

                • 5. Re: Strange error that occurs randomly...
                  Z4g0s Community Member

                  profilo is not a string but an Object (of the class Profilo) so I can not do what's in the example...