4 Replies Latest reply on Nov 18, 2010 10:16 AM by r.rubio

    Moving from 3.5 to 4.1 caused FlexShape to IUIComponent TypeCoercion error.

    r.rubio Level 1

      Following error occurs when loading a new application into a sandbox.  This code use to work in 3.5 but following error is produced when using 4.1sdk and flash builder 4.

       

      TypeError: Error #1034: Type Coercion failed: cannot convert mx.core::FlexShape@bd1f1f1 to mx.core.IUIComponent.

      at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()[E:\dev\4.x\frameworks\projects\f ramework\src\mx\core\Container.as:3921]

      at mx.core::Container/addChildAt()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Cont ainer.as:2606]

      at mx.core::Container/addChild()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Contai ner.as:2534]

      at mx.skins::RectangularBorder/initBackgroundImage()[E:\dev\4.x\frameworks\projects\framewor k\src\mx\skins\RectangularBorder.as:316]

      at mx.skins::RectangularBorder/updateDisplayList()[E:\dev\4.x\frameworks\projects\framework\ src\mx\skins\RectangularBorder.as:226]

      at mx.skins.halo::HaloBorder/updateDisplayList()[E:\dev\4.x\frameworks\projects\framework\sr c\mx\skins\halo\HaloBorder.as:228]

      at mx.skins::ProgrammaticSkin/validateDisplayList()[E:\dev\4.x\frameworks\projects\framework \src\mx\skins\ProgrammaticSkin.as:503]

      at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.x\frameworks\projects\framework \src\mx\managers\LayoutManager.as:663]

      at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:718]

      at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects \framework\src\mx\managers\LayoutManager.as:1072]

        • 1. Re: Moving from 3.5 to 4.1 caused FlexShape to IUIComponent TypeCoercion error.
          r.rubio Level 1

          More info.

           

          This occurs when executing initBackGroundImage call within RectangularBorder.as.

           

          // To optimize memory use, we've declared RectangularBorder to be a Shape.

                  // As a result, it cannot have any children.

                  // Make the backgroundImage a sibling of this RectangularBorder,

                  // which is positioned just on top of the RectangularBorder.

                  var childrenList:IChildList = parent is IRawChildrenContainer ?

                                                   IRawChildrenContainer(parent).rawChildren :

                                                   IChildList(parent);

           

                  const backgroundMask:Shape = new FlexShape();

                  backgroundMask.name = "backgroundMask";

                  backgroundMask.x = 0;

                  backgroundMask.y = 0;

                  childrenList.addChild(backgroundMask);

          In the case when loading a sandbox application childrenList is the Applicaiton container whoms addChild method expects an element of type IUIComponent.
          In file Container.as.
          // Throw an RTE if child is not an IUIComponent.
          var uiChild:IUIComponent = IUIComponent(child);
          Am i missing a step in 4.1 when loading a sandbox application?  Application is being loaded as child of boostrap.

          • 2. Re: Moving from 3.5 to 4.1 caused FlexShape to IUIComponent TypeCoercion error.
            r.rubio Level 1

            More info.

             

            Error occurs when i create the sandbox application domain as a child of the boostrap.

             

            i.e. loaderContext.applicationDomain = new ApplicationDomain(bootStrapAppDomain).

             

             

            If i dont use the boostrap application domain i do not get the error but it is not loaded as a child of the bootstrap and i get  a different set of errors.

             

            Any help greatly appreciated as to why loading as a child of bootstrap no longer works in 4.1.

            • 3. Re: Moving from 3.5 to 4.1 caused FlexShape to IUIComponent TypeCoercion error.
              Flex harUI Adobe Employee

              In Flex 4, you need to

              -includes=mx.managers.systemClasses.MarshallingSupport