2 Replies Latest reply on Dec 1, 2008 10:17 AM by Gregory Lafrance

    TypeError: Error #1034 Type Coercion failed

    sandwicense Level 1
      Can someone help me understand where the error is? I don't understand how to read the errors that the debugger outputs.

      TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls::Text@2f07ccf1 to mx.core.Container.
      at mx.controls::NavBar/_setTargetViewStack()
      at mx.controls::NavBar/checkPendingTargetStack()
      at mx.controls::NavBar/commitProperties()
      at mx.controls::ButtonBar/commitProperties()
      at mx.controls::ToggleButtonBar/commitProperties()
      at mx.core::UIComponent/validateProperties()
      at mx.managers::LayoutManager/validateClient()
      at mx.core::UIComponent/validateNow()
      at mx.core::UIComponent/creationCompleteHandler()
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()
      at mx.core::UIComponent/set initialized()
      at mx.managers::LayoutManager/doPhasedInstantiation()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/callLaterDispatcher2()
      at mx.core::UIComponent/callLaterDispatcher()
        • 1. Re: TypeError: Error #1034 Type Coercion failed
          Level 7
          If you run in debug mode instead of just the regular run mode, it will give
          you line numbers. But it looked like you tried to call a method on a text
          control that only exists on a container, or you passed a text control as an
          argument to something that needs a container.

          HTH;

          Amy

          "wallanceM" <webforumsuser@macromedia.com> wrote in message
          news:ggsshc$av6$1@forums.macromedia.com...
          > Can someone help me understand where the error is? I don't understand how
          > to
          > read the errors that the debugger outputs.
          >
          > TypeError: Error #1034: Type Coercion failed: cannot convert
          > mx.controls::Text@2f07ccf1 to mx.core.Container.
          > at mx.controls::NavBar/_setTargetViewStack()
          > at mx.controls::NavBar/checkPendingTargetStack()
          > at mx.controls::NavBar/commitProperties()
          > at mx.controls::ButtonBar/commitProperties()
          > at mx.controls::ToggleButtonBar/commitProperties()
          > at mx.core::UIComponent/validateProperties()
          > at mx.managers::LayoutManager/validateClient()
          > at mx.core::UIComponent/validateNow()
          > at mx.core::UIComponent/creationCompleteHandler()
          > at flash.events::EventDispatcher/dispatchEventFunction()
          > at flash.events::EventDispatcher/dispatchEvent()
          > at mx.core::UIComponent/dispatchEvent()
          > at mx.core::UIComponent/set initialized()
          > at mx.managers::LayoutManager/doPhasedInstantiation()
          > at Function/ http://adobe.com/AS3/2006/builtin::apply()
          > at mx.core::UIComponent/callLaterDispatcher2()
          > at mx.core::UIComponent/callLaterDispatcher()
          >


          • 2. Re: TypeError: Error #1034 Type Coercion failed
            Gregory Lafrance Level 6
            Usually this happens when you try to change the view of a ViewStack, such as:

            var myText:Text = new Text();
            ...
            myText.text = "productCatalog";
            ...
            myViewStack.selectedChild = myText;

            The ViewStack wants a container for selectedChild, but you are passing a Text object. It doesn't matter that the value of the Text object text property (productCatalog) might be the same as the name of a container object within the ViewStack.

            The following code illustrates the problem, with a slightly different error, and provides one solution: