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?
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;
}
}
}
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;
}
}
}
North America
Europe, Middle East and Africa
Asia Pacific