Skip navigation
Z4g0s
Currently Being Moderated

Strange error that occurs randomly...

Apr 2, 2012 5:41 AM

Tags: #flash_builder #flex #actionscript #flash_builder_4.5 #flex4.5

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?

 
Replies
  • Currently Being Moderated
    Apr 13, 2012 6:00 AM   in reply to Z4g0s

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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 6:33 AM   in reply to Z4g0s

    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;

                        }

              }

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points