18 Replies Latest reply on Sep 19, 2007 10:49 AM by kd213

    error #1034

    Level 7
      Hi All,
      Let me try again...
      I have a comboBox inside a Datagrid and I want to do some calculations after
      change the index on the comboBox
      My code is bellow and I have this error:
      var chosenItem:Object =
      ComboBox(event.currentTarget.itemEditorInstance).selectedItem;
      Error #1034: Type Coercion failed: cannot convert
      NewEstimate_inlineComponent1@c7050a1 to mx.controls.ComboBox.
      Please help.
      Rgds

      JFB

      public function calculateRateTotal(event:DataGridEvent):void{
      if (event.reason == DataGridEventReason.OTHER ||
      event.reason == DataGridEventReason.CANCELLED){
      // Do not update cell.
      return;
      }
      if(event.dataField == "rateid") {
      var chosenItem:Object =
      ComboBox(event.currentTarget.itemEditorInstance).selectedItem;
      var chosenRateId:int = chosenItem.rateid;

      }
      <mx:DataGrid id="price_dg" itemEditEnd="calculateRateTotal(event)" x="10"
      y="28" width="590" height="147" editable="true">
      <mx:columns>
      <mx:DataGridColumn headerText="Quantity" dataField="qty"/>
      <mx:DataGridColumn headerText="Rate Type" dataField="rateid"
      rendererIsEditor="true" width="120">
      <mx:itemRenderer >
      <mx:Component >
      <mx:VBox>
      <mx:ComboBox id="rate_cb" dataProvider="{outerDocument.acRate}"
      labelField="label" change="outerDocument.setRate(rate_cb)" width="120"/>
      </mx:VBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      <mx:DataGridColumn headerText="per Piece" dataField="perpiece"
      editable="false"/>
      <mx:DataGridColumn headerText="per 1000" dataField="per1000"
      editable="false" labelFunction="formatNumber"/>
      <mx:DataGridColumn headerText="Setup Fee" dataField="setupfee" />
      <mx:DataGridColumn headerText="Total" dataField="total" editable="false" />
      </mx:columns>
      </mx:DataGrid>


        • 1. Re: error #1034
          levancho Level 3
          you are trying to cast itemEditorInstance:IListItemRenderer to ComboBox
          thats not possible .
          this should work :
          ComboBox(event.currentTarget.itemEditorInstance.rate_cb).selectedItem;;
          • 2. Re: error #1034
            Level 7
            Thank for you reply...
            now i got this error at this line in the datagrid.as
            Rgds

            JFB


            if (itemEditorInstance && event.reason != DataGridEventReason.CANCELLED)
            {
            var newData:Object =
            itemEditorInstance[_columns[event.columnIndex].editorDataField];

            ERROR: #1069: Property text not found on NewEstimate_inlineComponent1 and
            there is no default value.

            "levancho" <webforumsuser@macromedia.com> wrote in message
            news:fcei40$aeb$1@forums.macromedia.com...
            > you are trying to cast itemEditorInstance:IListItemRenderer to ComboBox
            > thats not possible .
            > this should work :
            > ComboBox(event.currentTarget.itemEditorInstance.rate_cb).selectedItem;;


            • 3. Re: error #1034
              chris.huston.t10 Level 3
              Maybe you could simplify your code by removing the itemEditEnd, editable, and rendererIsEditor events and properties. Then, in your component, do:

              change="outerDocument.calculateRateTotal(rate_cb.selectedItem)"

              and change your function to:

              public function calculateRateTotal(chosenItem:Object):void {
              var chosenRateId:int = chosenItem.rateid;
              }

              It seems that this would make things easier to keep track of.
              Vygo
              • 4. Re: error #1034
                Level 7
                Thanks for you reply and help.
                But if a qty is update after setup comboBox I need to do the calculations
                also.
                In the other way I can track qty column or any other column and do the
                calculations.
                What do you think?
                Why the other way is not working? any ideas?
                Rgds

                JFB


                "Masamune" <huston@mgu.ac.jp> wrote in message
                news:fcf01c$p8o$1@forums.macromedia.com...
                > Maybe you could simplify your code by removing the itemEditEnd, editable,
                > and
                > rendererIsEditor events and properties. Then, in your component, do:
                >
                > change="outerDocument.calculateRateTotal(rate_cb.selectedItem)"
                >
                > and change your function to:
                >
                > public function calculateRateTotal(chosenItem:Object):void {
                > var chosenRateId:int = chosenItem.rateid;
                > }
                >
                > It seems that this would make things easier to keep track of.
                > Vygo
                >


                • 5. Re: error #1034
                  Level 7
                  The other thing is:
                  At the first time setting the row it's fine but if I already have the data
                  and getting from my database an putting to the datagrid, I want to do the
                  calculations in a auto way.
                  Tks

                  JFB

                  "Masamune" <huston@mgu.ac.jp> wrote in message
                  news:fcf01c$p8o$1@forums.macromedia.com...
                  > Maybe you could simplify your code by removing the itemEditEnd, editable,
                  > and
                  > rendererIsEditor events and properties. Then, in your component, do:
                  >
                  > change="outerDocument.calculateRateTotal(rate_cb.selectedItem)"
                  >
                  > and change your function to:
                  >
                  > public function calculateRateTotal(chosenItem:Object):void {
                  > var chosenRateId:int = chosenItem.rateid;
                  > }
                  >
                  > It seems that this would make things easier to keep track of.
                  > Vygo
                  >


                  • 6. Re: error #1034
                    Level 7
                    Hi levancho,
                    Looks like this error is after I click outside of the datagrid.
                    Why? What am I missing here?
                    Tks

                    JFB

                    "levancho" <webforumsuser@macromedia.com> wrote in message
                    news:fcei40$aeb$1@forums.macromedia.com...
                    > you are trying to cast itemEditorInstance:IListItemRenderer to ComboBox
                    > thats not possible .
                    > this should work :
                    > ComboBox(event.currentTarget.itemEditorInstance.rate_cb).selectedItem;;


                    • 7. Re: error #1034
                      levancho Level 3
                      var newData:Object =
                      itemEditorInstance[_columns[event.columnIndex].editorDataField];

                      ERROR: #1069: Property text not found on NewEstimate_inlineComponent1 and
                      there is no default value.

                      -----------------------


                      most likely : this "_columns[event.columnIndex].editorDataField" yeads to literal value of "text" to you endup with :

                      itemEditorInstance["text"] which is same as to do itemEditorInstance.text and most likely there is no property text in that itemEditorInstance



                      • 8. error #1034
                        levancho Level 3
                        from SDK :

                        editorDataField property

                        public var editorDataField:String = "text"
                        The name of the property of the item editor that contains the new data for the list item. For example, the default itemEditor is TextInput, so the default value of the editorDataField property is "text", which specifies the text property of the the TextInput control.


                        so that means you probably wanted to call editorDataField off of you r list item editor not "_columns[event.columnIndex]" ,, that means, most likely your syntax should be :

                        : maybe simply : itemEditorInstance[_columns[event.columnIndex]].editorDataField ???


                        • 9. Re: error #1034
                          Level 7
                          Great work... thank you.
                          I fixed this on friday using rendererIsEditor="true" editorDataField="id" in
                          my datagridcolumn.
                          Rgds

                          JFB

                          "levancho" <webforumsuser@macromedia.com> wrote in message
                          news:fclvqq$d3j$1@forums.macromedia.com...
                          > from SDK :
                          >
                          > editorDataField property
                          >
                          > public var editorDataField:String = "text"
                          > The name of the property of the item editor that contains the new data for
                          > the
                          > list item. For example, the default itemEditor is TextInput, so the
                          > default
                          > value of the editorDataField property is "text", which specifies the text
                          > property of the the TextInput control.
                          >
                          >


                          • 10. Re: error #1034
                            Level 7
                            One more thing Levancho,
                            After change the select in my comboBox, I have to click somewhere to fire
                            this event.
                            How can I fix this? I try to put my function in the change event but doesn't
                            work.
                            Thanks

                            JFB

                            "levancho" <webforumsuser@macromedia.com> wrote in message
                            news:fclvqq$d3j$1@forums.macromedia.com...
                            > from SDK :
                            >
                            > editorDataField property
                            >
                            > public var editorDataField:String = "text"
                            > The name of the property of the item editor that contains the new data for
                            > the
                            > list item. For example, the default itemEditor is TextInput, so the
                            > default
                            > value of the editorDataField property is "text", which specifies the text
                            > property of the the TextInput control.
                            >
                            >


                            • 11. Re: error #1034
                              levancho Level 3
                              how do you want it to work, to run as soon as you close combo box or?
                              • 12. Re: error #1034
                                Level 7
                                Yes after I do a seleccion in the combo, I want to fire the even... also if
                                after I change qty I want to update my calculations.
                                Tks

                                JFB

                                "levancho" <webforumsuser@macromedia.com> wrote in message
                                news:fcmc5l$qq8$1@forums.macromedia.com...
                                > how do you want it to work, to run as soon as you close combo box or?


                                • 13. Re: error #1034
                                  Level 7
                                  One thing is that after I select the rate I go to the database to get the
                                  percentage that I use in my calculations.
                                  Then fire my calculations function..
                                  Tks

                                  JFB

                                  "levancho" <webforumsuser@macromedia.com> wrote in message
                                  news:fcmc5l$qq8$1@forums.macromedia.com...
                                  > how do you want it to work, to run as soon as you close combo box or?


                                  • 14. Re: error #1034
                                    Level 7
                                    gggg... This is very frustrate it
                                    Now still can't fire the calculatoins after select comboBox or getting data
                                    from my database table.
                                    But If I try to save the data to table the rateid is null... why?
                                    I can't figure this out..... please help!!!

                                    Rgds
                                    JFB


                                    "levancho" <webforumsuser@macromedia.com> wrote in message
                                    news:fcmc5l$qq8$1@forums.macromedia.com...
                                    > how do you want it to work, to run as soon as you close combo box or?


                                    • 15. Re: error #1034
                                      Level 7
                                      Finally I got the error fixed..!!! ufff...
                                      Now only is missing the part to fire the calculations after select an Item
                                      on the comboBox.
                                      Rgds

                                      JFB

                                      "levancho" <webforumsuser@macromedia.com> wrote in message
                                      news:fcmc5l$qq8$1@forums.macromedia.com...
                                      > how do you want it to work, to run as soon as you close combo box or?


                                      • 16. Re: error #1034
                                        kd213
                                        Hi,
                                        I got the same error when i tried to embed an external swf file into a module and running it from my application. Everything is compiling file and this is a run-time error:

                                        TypeError: Error #1034: Type Coercion failed: cannot convert global@85fc041 to flash.display.DisplayObject.
                                        at MethodInfo-2985()
                                        at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                                        at flash.events::EventDispatcher/dispatchEvent()
                                        at ::ModuleInfoProxy/::moduleEventHandler()
                                        at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                                        at flash.events::EventDispatcher/dispatchEvent()
                                        at ::ModuleInfo/readyHandler()
                                        at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                                        at flash.events::EventDispatcher/dispatchEvent()

                                        Before loading the code:
                                        var dlg:IFlexDisplayObject = IFlexDisplayObject(m.factory.create());
                                        PopUpManager.addPopUp(dlg,this, true);
                                        PopUpManager.centerPopUp(dlg);

                                        If I just give DisplayObject instead of IFlexDisplayObj, it simply does not compile.
                                        • 17. Re: error #1034
                                          Level 7
                                          I think this is a general error trying to tell you that global@85fc041 is
                                          a different data type flash.display.DisplayObject.
                                          Rgds

                                          JFB

                                          "kd213" <webforumsuser@macromedia.com> wrote in message
                                          news:fcrhaq$fvd$1@forums.macromedia.com...
                                          > Hi,
                                          > I got the same error when i tried to embed an external swf file into a
                                          > module
                                          > and running it from my application. Everything is compiling file and this
                                          > is a
                                          > run-time error:
                                          >
                                          > TypeError: Error #1034: Type Coercion failed: cannot convert
                                          > global@85fc041 to
                                          > flash.display.DisplayObject.
                                          > at MethodInfo-2985()
                                          > at
                                          > flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio
                                          > n()
                                          > at flash.events::EventDispatcher/dispatchEvent()
                                          > at ::ModuleInfoProxy/::moduleEventHandler()
                                          > at
                                          > flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio
                                          > n()
                                          > at flash.events::EventDispatcher/dispatchEvent()
                                          > at ::ModuleInfo/readyHandler()
                                          > at
                                          > flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio
                                          > n()
                                          > at flash.events::EventDispatcher/dispatchEvent()
                                          >
                                          > Before loading the code:
                                          > var dlg:IFlexDisplayObject = IFlexDisplayObject(m.factory.create());
                                          > PopUpManager.addPopUp(dlg,this, true);
                                          > PopUpManager.centerPopUp(dlg);
                                          >
                                          > If I just give DisplayObject instead of IFlexDisplayObj, it simply does
                                          > not
                                          > compile.
                                          >


                                          • 18. Re: error #1034
                                            kd213 Level 1
                                            Yep you are right...
                                            But it is just a module, with nothing in it except another swf file. This swf is actually a different application altogether and the standalone swf works well. I compiled the module and got another swf and the moduleloader is getting this swf. I turned the debugger and the point where it broke was when the popup was looking for loading some DisplayObject type and found something else - which is understandable. Now what exactly is the appropriate object type for a module described above? I tried IFlexDisplayObject, IUIComponent and UIComponent -- but no luck