5 Replies Latest reply on Sep 16, 2010 9:48 AM by Shongrunden

    Type Coercion failed: cannot convert []@43aed59 to mx.core.IUIComponent. [FLEX4]

    CharlesBroughton_112

      I'm trying to make my own transition, since for some reason I get cryptic "duplication" errors when I try to put more than one effect inside a <stransitions> block... so I decided to make my own transition in ActionScript and apply it during onCreationComplete before using it.

       

      I get the above (title) cryptic error when trying to change state (currentState = "b_register").  Below is my transition init code.

       

          <fx:Script>
              <![CDATA[
                  import mx.effects.Dissolve;
                  import mx.effects.Glow;
                  import mx.effects.Move;
                  import mx.effects.Parallel;
                  import mx.effects.Resize;
                  import mx.effects.Sequence;
                  import mx.effects.easing.Bounce;
                  import mx.states.Transition;
                  
                  private function do_initEffects():void {
                      var t:Transition = new Transition();
                      
                      var step1:Resize = new Resize([Login]);
                          step1.duration = 500;
                          step1.heightTo = 160;
                          step1.easingFunction = Bounce.easeOut;
                      
                      var move1:Move = new Move();
                          move1.targets = new Array("{[Login_User], [Login_User_Label], [Login_Pass], [Login_Pass_Label]");
                          move1.duration = 500;
                          move1.yBy = 28;
                          move1.easingFunction = Bounce.easeOut;
                      
                      var step2:Dissolve = new Dissolve();
                          step2.targets = new Array("[Login_Email], [Login_Email_Label]");
                          step2.duration = 500;
                          step2.alphaFrom = 0;
                          step2.alphaTo = 1;
                      
                      var step3:Glow = new Glow();
                          step3.targets = new Array("[Login_Email], [Login_Email_Label]");
                          step3.duration = 1000;
                          step3.alphaFrom = 0.8;
                          step3.alphaTo = 0.0;
                          step3.blurXFrom = 10;
                          step3.blurXTo = 0;
                          step3.blurYFrom = 10;
                          step3.blurYTo = 0;
                      
                      var parallel:Parallel = new Parallel();
                          parallel.addChild(step1);
                          parallel.addChild(move1);
                      
                      var sequence:Sequence = new Sequence();
                          sequence.addChild(parallel);
                          sequence.addChild(step2);
                          sequence.addChild(step3);
                          
                      t.effect = sequence;
                      t.fromState = "b_login";
                      t.toState = "b_register";
                      super.transitions.push(t);
                  }
              ]]>
          </fx:Script>

       

      Und... here is the full error message I get inside a debug projector:

       

      TypeError: Error #1034: Type Coercion failed: cannot convert []@43ad719 to mx.core.IUIComponent.
          at mx.effects.effectClasses::ResizeInstance/startResizeTween()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\effectClasses\ResizeInstance.as:601]
          at mx.effects.effectClasses::ResizeInstance/play()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\effectClasses\ResizeInstance.as:455]
          at mx.effects::EffectInstance/startEffect()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\EffectInstance.as:680]
          at mx.effects.effectClasses::ParallelInstance/play()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\effectClasses\ParallelInstance.as:312]
          at mx.effects::EffectInstance/startEffect()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\EffectInstance.as:680]
          at mx.effects.effectClasses::SequenceInstance/playCurrentChildSet()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\effectClasses\SequenceInstance.as:551]
          at mx.effects.effectClasses::SequenceInstance/playNextChildSet()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\effectClasses\SequenceInstance.as:577]
          at mx.effects.effectClasses::SequenceInstance/play()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\effectClasses\SequenceInstance.as:333]
          at mx.effects::EffectInstance/startEffect()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\EffectInstance.as:680]
          at mx.effects::Effect/play()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\Effect.as:1214]
          at mx.core::UIComponent/commitCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9828]
          at mx.core::UIComponent/setCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9701]
          at mx.core::UIComponent/set currentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6087]
          at Kommunicate/LoginSwitch_clickHandler()[C:\Users\Charles\Adobe Flash Builder 4\Kommunicate\src\Kommunicate.mxml:165]
          at Kommunicate/__Login_Switch_click()[C:\Users\Charles\Adobe Flash Builder 4\Kommunicate\src\Kommunicate.mxml:187]

       


      [Login] is a PANEL, is a panel not an IUIComponent?  If not, how would I animate a PANEL resizing?

       

          <s:Panel width="250" height="140" title="Login" horizontalCenter="0" verticalCenter="0" id="Login"
                   includeIn="b_login,b_register" title.b_register="Register">
        • 1. Re: Type Coercion failed: cannot convert []@43aed59 to mx.core.IUIComponent. [FLEX4]
          Shongrunden Adobe Employee

          I think you might be setting your targets arrays incorrectly, try changing lines like this:

           

          step2.targets = new Array([Login_Email], [Login_Email_Label]);

           

          to this:

           

          step2.targets = new Array(Login_Email, Login_Email_Label);
          1 person found this helpful
          • 2. Re: Type Coercion failed: cannot convert []@43aed59 to mx.core.IUIComponent. [FLEX4]
            CharlesBroughton_112 Level 1
                <fx:Script>
                    <![CDATA[
                        import mx.effects.Dissolve;
                        import mx.effects.Glow;
                        import mx.effects.Move;
                        import mx.effects.Parallel;
                        import mx.effects.Resize;
                        import mx.effects.Sequence;
                        import mx.effects.easing.Bounce;
                        import mx.states.Transition;
                       
                        // ENTRY POINT: APPLICATION.EVENTS.ONCREATIONCOMPLETE
                        private function do_initEffects():void {
                            var t:Transition = new Transition();
                            var step1:Resize = new Resize(Login);
                                step1.duration = 500;
                                step1.heightTo = 160;
                                step1.easingFunction = Bounce.easeOut;
                            var move1:Move = new Move();
                                move1.targets = new Array(Login_User, Login_User_Label, Login_Pass, Login_Pass_Label);
                                move1.duration = 500;
                                move1.yBy = 28;
                                move1.easingFunction = Bounce.easeOut;
                            var step2:Dissolve = new Dissolve();
                                step2.targets = new Array(Login_Email, Login_Email_Label);
                                step2.duration = 500;
                                step2.alphaFrom = 0;
                                step2.alphaTo = 1;
                            var step3:Glow = new Glow();
                                step3.targets = new Array(Login_Email, Login_Email_Label);
                                step3.duration = 1000;
                                step3.alphaFrom = 0.8;
                                step3.alphaTo = 0.0;
                                step3.blurXFrom = 10;
                                step3.blurXTo = 0;
                                step3.blurYFrom = 10;
                                step3.blurYTo = 0;
                            var parallel:Parallel = new Parallel();
                                parallel.addChild(step1);
                                parallel.addChild(move1);
                            var sequence:Sequence = new Sequence();
                                sequence.addChild(parallel);
                                sequence.addChild(step2);
                                sequence.addChild(step3);
                            t.effect = sequence;
                            t.fromState = "b_login";
                            t.toState = "b_register";
                            super.transitions.push(t);
                        }
                    ]]>
                </fx:Script>

             

            Now nothing happens... No errors, no warnings, no effects.  The state is b_login, I click a button which code says: currenState="b_register" so why ar eno effects played?  (the above code doiniteffects is called onCreationComplete of s:application... so why is it not working?)

            • 4. Re: Type Coercion failed: cannot convert []@43aed59 to mx.core.IUIComponent. [FLEX4]
              Gregory Lafrance Level 6

              Better yet, how about this:

               

              step2.targets = [Login_Email, Login_Email_Label];

               

              If this post answers your question or helps, please mark it as such.


              Greg Lafrance - Flex 2 and 3 ACE certified

              www.ChikaraDev.com

              Flex Training and Support Services

              • 5. Re: Type Coercion failed: cannot convert []@43aed59 to mx.core.IUIComponent. [FLEX4]
                Shongrunden Adobe Employee

                So I tried your updated code with a simple sample application and it seems to work:

                <?xml version="1.0" encoding="utf-8"?>
                <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"
                               creationComplete="do_initEffects()">
                    <fx:Script>
                        <![CDATA[
                            import mx.effects.Dissolve;
                            import mx.effects.Glow;
                            import mx.effects.Move;
                            import mx.effects.Parallel;
                            import mx.effects.Resize;
                            import mx.effects.Sequence;
                            import mx.effects.easing.Bounce;
                            import mx.states.Transition;
                           
                            // ENTRY POINT: APPLICATION.EVENTS.ONCREATIONCOMPLETE
                            private function do_initEffects():void {
                                var t:Transition = new Transition();
                                var step1:Resize = new Resize(Login);
                                step1.duration = 500;
                                step1.heightTo = 160;
                                step1.easingFunction = Bounce.easeOut;
                                var move1:Move = new Move();
                                move1.targets = new Array(Login_User, Login_User_Label, Login_Pass, Login_Pass_Label);
                                move1.duration = 500;
                                move1.yBy = 28;
                                move1.easingFunction = Bounce.easeOut;
                                var step2:Dissolve = new Dissolve();
                                step2.targets = new Array(Login_Email, Login_Email_Label);
                                step2.duration = 500;
                                step2.alphaFrom = 0;
                                step2.alphaTo = 1;
                                var step3:Glow = new Glow();
                                step3.targets = new Array(Login_Email, Login_Email_Label);
                                step3.duration = 1000;
                                step3.alphaFrom = 0.8;
                                step3.alphaTo = 0.0;
                                step3.blurXFrom = 10;
                                step3.blurXTo = 0;
                                step3.blurYFrom = 10;
                                step3.blurYTo = 0;
                                var parallel:Parallel = new Parallel();
                                parallel.addChild(step1);
                                parallel.addChild(move1);
                                var sequence:Sequence = new Sequence();
                                sequence.addChild(parallel);
                                sequence.addChild(step2);
                                sequence.addChild(step3);
                                t.effect = sequence;
                                t.fromState = "b_login";
                                t.toState = "b_register";
                                super.transitions.push(t);
                            }
                        ]]>
                    </fx:Script>
                    <s:states>
                        <s:State  name="b_login" />
                        <s:State name="b_register" />
                    </s:states>
                   
                    <s:controlBarContent>
                        <s:Button label="toggle state" click="currentState=currentState=='b_login'?'b_register':'b_login'" />
                    </s:controlBarContent>
                   
                    <mx:Canvas>
                        <mx:Button id="Login_Email" label="Login_Email" y="0" />
                        <mx:Button id="Login_Email_Label" label="Login_Email_Label" y="30" />
                        <mx:Button id="Login_User" label="Login_User" y="60" />
                        <mx:Button id="Login_User_Label" label="Login_User_Label" y="90" />
                        <mx:Button id="Login_Pass" label="Login_Pass" y="120" />
                        <mx:Button id="Login_Pass_Label" label="Login_Pass_Label" y="150" />
                        <mx:Button id="Login" label="Login" y="180" />
                    </mx:Canvas>
                   
                </s:Application>

                 

                I noticed that you are using the mx effects so I used mx components.  If you are using spark components you will need to upgrade to the spark effects.  Can you provide a small sample application like the one above that demonstrates it not working?