Problem:
Something is receiving the wrong data type and it cannot be converted. For example, a function is expecting a string and we pass it an Array.
This also occurred in when I was passing an Array to a function that expected another data type.
The error detail is "cannot convert []@e1f73f9 mx.core.IUIComponent."
NOTICE - The value I am passing to the "target" property is an Array because the value is enclosed in brackets "[myvalue]". This would work if the property was "targets". The property "target" expects an object.
-
// INCORRECT
-
<mx:Resize target="{[eventDescription]}" duration="400" />
-
-
// CORRECT - Notice I removed the Array brackets
-
<mx:Resize target="{eventDescription}" duration="400" />
In this next example, an XMLList cannot be converted into an Array, which is what this component needs.
The error details is "cannot convert XMLList@37ace21 to Class."
-
public function tabBarHandler(event:ItemClickEvent):void {
-
-
var menuitems:XML = event.item.menuitems as XML;
-
-
// this converts an xml list into a array collection but the tab bar cannot accept an xmllist data type
-
// you *CAN* use this method if your data provider can accept an ArrayCollection
-
//var menuDP:ArrayCollection = new ArrayCollection(new XMLListCollection(event.item.menuitems.submenu as XMLList).toArray());
-
-
// in our case since we *CANNOT* we manually convert it to an array and then add it to the tabbar
-
for each (var menuitem:XML in menuitems.submenu) {
-
-
// create a new object and assign the properties to it from the xml node
-
var newItem:Object = new Object();
-
newItem.label = menuitem.@label;
-
newItem.link = menuitem.@link;
-
// optionally create a reference to the original xmlnode
-
newItem.menuitem = menuitem;
-
// add item to the array collection
-
menuDP.addItem(newItem);
-
-
trace(menuitem.@label);
-
-
}
-
-
// add new menuDP array collection to our tab bar
-
subMenuBar.dataProvider = menuDP;
-
}
Please reply in the comments below if this helped you or not. You can also use the Error Lookup Tool to look up Flex compiler or runtime errors. more info...
Judah,
Great blog. Very helpful in solving Flex errors. Here is a totally unrelated question. How do show code as 'code' in blog. IT looks like from the source code that you have multiple Div tags and lists etc... Is this a plugin or part of a theme, or something else.
Thanks in advance,
Curtis J. Morley
Curtis,
I use iG:Syntax Hiliter (http://blog.igeek.info/wp-plugins/igsyntax-hiliter/). I modified the code a bit to remove the fixed width issue. You can compare the code. So far it's worked pretty well. :)
Another instance this error occors when trying to add a Sprite to a Container.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Sprite@14b5401 to mx.core.IUIComponent.
This is the code:
var bar:Sprite = new Sprite();
bar.graphics.lineStyle(5, 0xFF0000);
bar.graphics.moveTo(100, 100);
bar.graphics.lineTo(200, 100);
bar.addEventListener(MouseEvent.CLICK, clickHandler);
// this refers to the application / container
this.addChild(bar);
Change the reference from "this" to "rawChildren":
rawChildren.addChild(bar);
Hi
I love you man!
This blog have helped me so many times.
I must say that the main blog did not help me this this time, but your latest comment was right on spot.
I started on Flex from Flash just a week ago, so this kind of errors is new to me.
Thank you.
U r Genius!!!!!! Thanks a lot..
Hi
In my application i want to perform some operation on click a column in dataGrid so i am using item click event of datagrid.
Signature of the Function to be executed is :
private function showOrderDetail(event:ListEvent):void
{
// some operation
}
code in dataGrid :
itemClick = "showOrderDetail(event)"
I am getting the runtime error saying that
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@19d9cc1 to mx.events.ListEvent.
Help me out.
Regards,
Asha
@Asha - the click event is getting passed a mouse event. so the event handler is not getting the correct event type passed to it:
Hi
In my application i want to perform some operation on click a column in dataGrid so i am using item click event of datagrid.
Signature of the Function to be executed is :
private function showOrderDetail(event:ListEvent):void
{
// some operation
}
code in dataGrid :
itemClick = "showOrderDetail(event)"
I am getting the runtime error saying that
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@19d9cc1 to mx.events.ListEvent.
Help me out.
Regards,
Asha
Hi
If i make that change it will result in a comiler error
1067 : Implicit coericon of a value of type mx.events:ListEvent to an unrelated evnt type flash.events:MouseEvent
Regards,
Asha
Hi Asha,
If you are using module loader please insert following code in your main application file,
import mx.managers.*;
private var _dragManager:DragManager;
private var _historyManager:HistoryManager;
private var _popupManager:PopUpManager;
Regards,
Pradip jadhav
Hi,
I am using Flex and a PHP file that is parsing JSON data. When I try to debug the flex file (the data is not being displayed in a data table) I get this error: Error #1034: Type Coercion failed: cannot convert "[{"id":"2","name":"Strapless Wedding Dress Tips","author":"Ramona Waters","rating":"0"},{"id":"3","name":"Coordinating Your Brides Maids","author":"Ericka Brown","rating":"0"}]" to mx.controls.Alert.
I am a flex newbie and need help on how to resolve this please.
@Keisha - It could be a couple things. I tend to think that the issue is malformed JSON data. The quotes may not be correct. It could also be the way you are applying it to the Data Grid. Couple things I would do:
1. validate the json data. what JSON interpreter are you using? i would use the one from as3corelib. set the result type to plain text and then trace that value. take that value and paste it into a JSON validator. http://www.google.com/search?q=json+validator
2. post your code to flex coders list to have other devs take a look at it (you can't do that here bc wordpress mangles it up).
The data is valid json according to the JSON Validator. I am also using the as3corelib with the result format set to text. I did sign up to flex coders, so I will see what they suggest. It may be something simple like the way it is going into the grid like you said. Thanks for your suggestions!
Hey, I just wanted to say that I had an issue that was solved by replacing this with rawChildren. Thank you very much, you helped me out immensely :)
I have a MXML file as follows
it works well. Howeve, when I replace
with
i.e., using resultHandler(event) to handle the received data. I got the following error messages. I could not figure out why? Please help.
I have a MXML file as follows
it works well. Howeve, when I replace
with
i.e., using resultHandler(event) to handle the received data. I got the following error messages. I could not figure out why? Please help.
TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@36f5741 into Array?
at TEST2/resultHandler()[C:\Documents and Settings\Administrator\My Documents\Flex Builder 3\TEST2\src\TEST2.mxml:17]
at TEST2/__http_result()[C:\Documents and Settings\Administrator\My Documents\Flex Builder 3\TEST2\src\TEST2.mxml:23]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\mxml\HTTPService.as:290]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:193]
at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]
at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]
at flash.events::EventDispatcher/dispatchEventFunction()
ei ,
Have you encountered this kind of error in Flex
"Type Coercion failed: cannot convert mx.charts.events::ChartIemEvent to ListEvent"
Thanks
Cyianite
hi,
private function onResultHttpService(event:ResultEvent):void
{
var viewXMLList:XMLList = event.result.view;
var len:Number = viewXMLList.length();
var containerWindowManagerHash:Object = new Object();
for(var i:Number = 0; i < len; i++) // Loop through the view nodes
{
// Create a canvas for each view node.
var canvas:Group = new Group();
var label:Label = viewXMLList[i].@label;
canvas.addElement(label);
canvas.percentWidth=100;
canvas.percentHeight=100;
viewStack.addChild(canvas);
// Create a Manager for each view.
var manager:PodLayoutManager = new PodLayoutManager();
manager.container = canvas;
manager.id = viewXMLList[i].@id;
manager.addEventListener(LayoutChangeEvent.UPDATE, StateManager.setPodLayout);
podDataDictionary[manager] = viewXMLList[i].pod;
podLayoutManagers.push(manager);
}
I have been trying to solve this problem so hard but i m not able to solve the error. Please help me....
I get the following error
TypeError: Error #1034: Type Coercion failed: cannot convert XML@e49aa41 element to XMLList.
at dashboard/onResultHttpService()[D:\SBZala\samruddhi\flexProjects\dashboard\src\dashboard.mxml:58]
at dashboard/__onHttpService_result()[D:\SBZala\samruddhi\flexProjects\dashboard\src\dashboard.mxml:194]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:979]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at DirectHTTPMessageResponder/completeHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:446]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Sorry,
please ignore the above error. The following is the error
TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@e9c4041 to spark.components.Label.
at dashboard/onResultHttpService()[D:\SBZala\samruddhi\flexProjects\dashboard\src\dashboard.mxml:62]
at dashboard/__onHttpService_result()[D:\SBZala\samruddhi\flexProjects\dashboard\src\dashboard.mxml:190]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:979]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at DirectHTTPMessageResponder/completeHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:446]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
@Sam
This line is creating the error:
var label:Label = viewXMLList[i].@label;
It should be something like this:
var label:Label = new Label();
label.text = viewXMLList[i].@label;
Judah,
Thanks for taking out time and helping me...
i did it like u said but now i m getting a new error... :(
TypeError: Error #1034: Type Coercion failed: cannot convert spark.components::Group@e53e851 to mx.core.INavigatorContent.
at mx.controls::NavBar/childAddHandler()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\controls\NavBar.as:1183]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\UIComponent.as:11749]
at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\Container.as:3911]
at mx.core::Container/addChildAt()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\Container.as:2578]
at mx.containers::ViewStack/addChildAt()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\containers\ViewStack.as:1423]
at mx.core::Container/addChild()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\Container.as:2496]
at dashboard/onResultHttpService()[D:\SBZala\samruddhi\flexProjects\dashboard\src\dashboard.mxml:66]
at dashboard/__onHttpService_result()[D:\SBZala\samruddhi\flexProjects\dashboard\src\dashboard.mxml:190]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:979]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at DirectHTTPMessageResponder/completeHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:446]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Hi Judah,
I am working on line charts in flex using pure as3
and trying to apply itemrenderer to the linseries
lineseriesInstance.setStyle("stroke",new ClassFactory(StrokeClass));
where StrokeClass is my custom class inherited from
mx.graphics.Stroke
it generates follwing error please help me.
TypeError: Error #1034: Type Coercion failed: cannot convert mx.core::ClassFactory@2caada1 to mx.graphics.IStroke.
at mx.charts.series::LineSeries/describeData()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\series\LineSeries.as:1202]
at mx.charts.chartClasses::DataTransform/describeData()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\DataTransform.as:230]
at mx.charts.chartClasses::AxisBase/describeData()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\AxisBase.as:177]
at mx.charts.chartClasses::NumericAxis/get dataDescriptions()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\NumericAxis.as:1033]
at mx.charts.chartClasses::NumericAxis/autoGenerate()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\NumericAxis.as:1050]
at mx.charts.chartClasses::NumericAxis/updateCache()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\NumericAxis.as:761]
at mx.charts.chartClasses::NumericAxis/update()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\NumericAxis.as:884]
at mx.charts.chartClasses::NumericAxis/getLabelEstimate()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\NumericAxis.as:645]
at mx.charts::AxisRenderer/measureLabels()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\AxisRenderer.as:1740]
at mx.charts::AxisRenderer/calcRotationAndSpacing()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\AxisRenderer.as:1459]
at mx.charts::AxisRenderer/adjustGutters()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\AxisRenderer.as:1326]
at mx.charts.chartClasses::CartesianChart/updateAxisLayout()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\CartesianChart.as:1873]
at mx.charts.chartClasses::CartesianChart/updateDisplayList()[C:\Work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\CartesianChart.as:1355]
at mx.core::UIComponent/validateDisplayList()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:6214]
at mx.managers::LayoutManager/validateDisplayList()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:602]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:675]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8460]
at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8403]
@rahul - i think it could be you need to cast it as a stroke.
lineseriesInstance.setStyle(“stroke”, Stroke(new ClassFactory(StrokeClass)));
also try it without the class factory and go from there...
lineseriesInstance.setStyle("lineStroke", new Stroke(0xFF0000, 4));
ps it may need to be "lineStroke"