TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@37ace21 to Class.

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


// CORRECT - Notice I removed the Array brackets

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…

This entry was posted in Errors, Flex. Bookmark the permalink.

34 Responses to TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@37ace21 to Class.

  1. 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

  2. Judah says:

    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. :)

  3. Judah says:

    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);

  4. Mikael says:

    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.

  5. Sourav Dutta says:

    U r Genius!!!!!! Thanks a lot..

  6. Asha says:

    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

  7. Judah says:

    @Asha – the click event is getting passed a mouse event. so the event handler is not getting the correct event type passed to it:

    [as]
    private function showOrderDetail(event:ListEvent):void {
    //should be:
    private function showOrderDetail(event:MouseEvent):void {
    [/as]

  8. Asha says:

    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

  9. Asha says:

    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

  10. Pradip Jadhav says:

    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

  11. Keisha says:

    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.

  12. Judah says:

    @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).

  13. Keisha says:

    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!

  14. kevin says:

    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 :)

  15. Felix says:

    I have a MXML file as follows

    [Code]

    [/code]

    it works well. Howeve, when I replace

    [Code]

    [/code]
    with

    [Code]

    [/code]

    i.e., using resultHandler(event) to handle the received data. I got the following error messages. I could not figure out why? Please help.

    [Code]
    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()
    [/code]

  16. Felix says:

    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()

  17. cyianite says:

    ei ,
    Have you encountered this kind of error in Flex
    “Type Coercion failed: cannot convert mx.charts.events::ChartIemEvent to ListEvent”

    Thanks
    Cyianite

  18. Samruddhi says:

    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()

  19. Samruddhi says:

    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()

    • Judah says:

      @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;

  20. Samruddhi says:

    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()

  21. rahul says:

    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]

    • Judah says:

      @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”

  22. Raghuvir Konanki says:

    Hi,

    I’m having somewhat the same trouble. My database table consists of “double” type columns. While my Action Script class which is mapped to my hibernate class has its setter and getter methods also returning double values which are brought from the database as it is.
    Since double data type doesn’t exist in flex I’ve used the “Number” type in my action script which maps to the hibernate class.
    At run time it throws this error in flex when I’m trying to display this data in my mxml.

    TypeError: Error #1034: Type Coercion failed: cannot convert Object@5c82401 to mx.messaging.messages.IMessage.

    #Epic fail. Flex.

    Need some more info on this let me know. But for now I really need the solution for this.

    Thanks,
    Raghu

  23. jess says:

    wer can i repair the error?????? at actionscript isit???

  24. jess says:

    my error

    Type Error: Error #1034: Type Coercion failed cannot convert flash.display:: MovieClip@2a9edccl to fl.motion. Animator Factory.

  25. Munaza says:

    Thanks alot judah.. This blog is really helpful

  26. Kajendran says:

    i have xml which was retrieved from the database

    !
    @
    #
    $
    %
    ^
    &
    *
    (
    )
    {
    |
    \
    ?

    >

    <

    if i tried to load these into dropdownlist by using this

    it shows an error such That
    “#Error 1085 The element type “</character" must be terminated by the matching end-tag"

  27. Jakob says:

    Dear Judah,

    I am new to AS3. I want to display a message for 3 secs. when the user rolls over a button, only once per session. The variables: nxt is the button, popup is the TIMER variable, see/notsee are boolean flags set when the message is displayed/hidden respectively and nxt_msg is the message sprite. The relevant code is:

    nxt.addEventListener(MouseEvent.ROLL_OVER,display_pop);
    popup.addEventListener(TimerEvent.TIMER, display_pop);
    
    function display_pop (event:MouseEvent):void {
    				if(see==false) {
    					see = true;
    					nxt_msg.x = 437;
    					nxt_msg.y = 354;
    					popup = new Timer(3000,1);
    					popup.start();
    					nxt_msg.visible = true;
    				}
    				else {if(notsee==false) {
    						notsee = true;
    						nxt_msg.x = 165;
    						nxt_msg.y = 405;
    						popup = new Timer(3000,1);
    						popup.start();
    						nxt_msg.visible = false;}		
    				     }
    	 }	

    There are no syntax errors, but the baby is comatose! Actually, the message appears and stays as long as the mouse is over the button, on rollout nothing happens, and then on rollover the message disappears! Will you please tell me what’s wrong here?

    Sincerely,
    Jakob
    Montreal

  28. Jakob says:

    Woops! I just forgot this little titbit: at the beginning of the program, I initialized popup like so – var popup:Timer = new Timer(3000,1);

  29. judah says:

    Ran into this again, Type Coercion failed: cannot convert XMLList@10929fd81 to XML.

    In this case when you access an XML node like so:

     something.name = _data.asset

    and the XML is:

    <root>
        <asset name="product1" />
    </root>
    

    the result is an XMLList of one item. To fix you have to get the first and only item like so:

    var object:XML = _data.asset[0];

    or cast it to the type XML

    var object:XML = XML(_data.asset);

    • judah says:

      Oops. It cannot be cast to XML which is the cause of this error so this does not work:

      var object:XML = XML(_data.asset);

      While this one does:

      var object:XML = _data.asset[0];

      I think this is a quirky behavior on using XML in AS3. Basically if you access xml.node then it returns a XMList but if you access xml.node.@item it treats node as XML. :P

Leave a Reply

Your email address will not be published. Required fields are marked *

Wrap your code before posting! Click the links below:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">