17 Replies Latest reply on Jan 28, 2010 6:40 PM by toft

    DropDownList bug ?

    toft Level 1

      I`m using a spark DropDownList in a file imported to FB beta 2 from Flex 3.

       

      I have tried in every way to populate it by binding it to an ArrayCollection.

      When running the file in debugger I can see the values in the dataprovider property of the control but nothing shows up in the output file. However, the dropdown list is higher when there are more items in the arraycollection. But no text shows up !!

       

      I have tried all the same methods on an mx combobox and it works perfectly.

       

      Is it a bug or am I missing something?

       

        • 1. Re: DropDownList bug ?
          nathanbie

          Example of the code you're using would be beneficial in tracking down the issue.

          • 2. Re: DropDownList bug ?
            toft Level 1

            In one MXML file:

             

            (app creationComplete = init();)

            .......

            (script block):

             

            import mx.collections.ArrayCollection;


            [Bindable]
            private var acChannels:ArrayCollection;


            private function init():void{

            acChannels =new ArrayCollection();
            acChannels.addItem({label:" channel...",data:0});
            acChannels.addItem({label:"NRK",data:1});
            acChannels.addItem({label:"NRK2",data:2});
            acChannels.addItem({label:"NRK3",data:3});

            //ddlChannels.dataProvider = acChannels;

            }

            .......


            <s:DropDownList id="ddlChannels"
            width="100"
            justificationRule="auto"
            dataProvider="{acChannels}"/>

            • 3. Re: DropDownList bug ?
              nathanbie Level 1

              I tested the following code and I could not reproduce your problem. All four items displayed on the drop down list. Are you using custom skins or css within your application?

               

               

              <?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/halo"
                                minWidth="1024"
                                minHeight="768"
                                initialize="init();"
                                >
                   <fx:Declarations>
                        <!-- Place non-visual elements (e.g., services, value objects) here -->
                   </fx:Declarations>
              
                   <fx:Script>
                        <![CDATA[
                             import mx.collections.ArrayCollection;
                             
                             [Bindable]
                             private var acChannels:ArrayCollection;
                             
                             private function init():void{
                                  acChannels =new ArrayCollection();
                                  acChannels.addItem({label:" channel...",data:0});
                                  acChannels.addItem({label:"NRK",data:1});
                                  acChannels.addItem({label:"NRK2",data:2});
                                  acChannels.addItem({label:"NRK3",data:3});
                                  //ddlChannels.dataProvider = acChannels;
                             }
                        ]]>
                   </fx:Script>
                   
                   <s:DropDownList id="ddlChannels"
                                       width="100"
                                       justificationRule="auto"
                                       dataProvider="{acChannels}"/>
              </s:Application>
              
               
              
              • 4. Re: DropDownList bug ?
                flairjax Level 1

                Are you using the dropdown inside of a popup?  There is a bug where the dropdown inside of a popup doesn't position correctly and has some other issues.  This may not be your issue though.

                 

                J

                • 5. Re: DropDownList bug ?
                  toft Level 1

                  Thanks for your input nathanbie.

                   

                  Yes your script works here too. But I`m still unable to make the original work. I have commented out every bit of code thats not relevant, removed refs to css / skins, in other words simplified it to the bone, and still the ddl turns up empty. Seems to me that importing Flex3 projects to FB4 is not a good idea (?)

                  • 6. Re: DropDownList bug ?
                    toft Level 1

                    Thanks Dallas.

                     

                    Your idea doesnt apply to my script but I`ll keep it in mind for later.

                    • 7. Re: DropDownList bug ?
                      John Hall Level 4

                      This isn't meant to be patronizing but I spent about 10 minutes the other day before I realized the default font color was white and couldn't see the data. Any chance?

                      • 8. Re: DropDownList bug ?
                        toft Level 1

                        Dont think so John. There is a mouseover effect that darkens the background so in case of white letters they would show if they were there.

                        • 9. Re: DropDownList bug ?
                          nathanbie Level 1

                          toft wrote:

                          Seems to me that importing Flex3 projects to FB4 is not a good idea (?)

                           

                          Yes, you're better off starting a new Flex 4 project and copying over code than importing a F3 project. 

                          • 10. Re: DropDownList bug ?
                            Peter deHaan Level 4

                            @toft,

                             

                            Can you post your greatly simplified test case here and a few of us can take a look?

                             

                            Peter

                            • 11. Re: DropDownList bug ?
                              toft Level 1

                              Hi Peter

                               

                              Here is a simple version.

                               

                               

                              Main MXML:

                               

                               

                              <?xml version="1.0" encoding="utf-8"?>
                              <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
                                    layout="absolute"
                                    width="200" height="280"
                                    showStatusBar="false"
                                    pageTitle="AlarmClockTV"
                                    creationComplete="init();">

                              <mx:Script>
                                <![CDATA[
                                
                                 import components.AlarmClockLine.AlarmClockLine;
                                 import mx.containers.HBox;
                                
                                 private function init():void
                                 {
                                  var acl:AlarmClockLine = new AlarmClockLine(); 
                                  acl.x = 0;
                                 
                                  var hb:HBox = new HBox();
                                 
                                  hb.y = 50;
                                  hb.x = 0;
                                  hb.percentWidth = 100;
                                  
                                  hb.addChild(acl);
                                  vb.addChild(hb);
                                 }
                                ]]>
                              </mx:Script>

                              <mx:Canvas id="cContainer" width="100%" height="100%"> 
                                <mx:VBox x="0" y="72" width="100%" height="100%" id="vb" horizontalAlign="center" verticalGap="15">
                                </mx:VBox> 
                              </mx:Canvas>

                              </mx:WindowedApplication>

                               

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

                               

                              AlarmClockLine component:

                               

                              <?xml version="1.0" encoding="utf-8"?>
                              <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
                                   xmlns:s="library://ns.adobe.com/flex/spark"
                                   height="20"    
                                   backgroundAlpha="0.0"
                                   creationComplete="initComp();"
                                   width="200">
                               
                              <mx:Script>
                                <![CDATA[
                                 import mx.collections.ArrayCollection;
                                 import mx.controls.Alert
                                
                                 private var acChannels:ArrayCollection;
                                 private function initComp():void
                                 {
                                  acChannels = new ArrayCollection();
                                  acChannels.addItem({label:"One", data:1});
                                  acChannels.addItem({label:"Two", data:2});
                                  acChannels.addItem({label:"Tree", data:3});
                                  ddlChannels.dataProvider = acChannels;
                                  //Alert.show("initComp is working");
                                 }
                                ]]>
                              </mx:Script>
                               
                                <s:DropDownList
                                 id="ddlChannels"
                                 width="90"
                                 justificationRule="auto">  
                                </s:DropDownList>

                              </mx:Canvas>

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

                              • 12. Re: DropDownList bug ?
                                Flex harUI Adobe Employee

                                Just to double-check.  Did you actually use this code in a new project and

                                had the same problem?  Are you using embedded fonts in the original project?

                                • 13. Re: DropDownList bug ?
                                  Peter deHaan Level 4

                                  This works for me:

                                   

                                  <?xml version="1.0" encoding="utf-8"?>
                                  <!-- 4.0.0.13771 -->
                                  <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                 xmlns:s="library://ns.adobe.com/flex/spark"
                                                 creationComplete="initComp();">
                                      
                                      <fx:Script>
                                          <![CDATA[
                                              import mx.collections.ArrayCollection;
                                              import mx.controls.Alert;
                                              
                                              private var acChannels:ArrayCollection;
                                              private function initComp():void
                                              {
                                                  acChannels = new ArrayCollection();
                                                  acChannels.addItem({label:"One", data:1});
                                                  acChannels.addItem({label:"Two", data:2});
                                                  acChannels.addItem({label:"Tree", data:3});
                                                  ddlChannels.dataProvider = acChannels;
                                                  // Alert.show("initComp is working");
                                              }
                                          ]]>
                                      </fx:Script>
                                      
                                      <s:DropDownList id="ddlChannels"
                                                      width="90"
                                                      justificationRule="auto" />
                                      
                                  </s:Application>
                                  

                                   

                                  Peter

                                  • 14. Re: DropDownList bug ?
                                    toft Level 1

                                    The code is from the original project. I`ve just deleted a lot of it.

                                    No embedded fonts as far as I know.

                                    • 15. Re: DropDownList bug ?
                                      toft Level 1

                                      Thanks Peter.

                                       

                                      Your code works here too but the setup is quite different from my script.

                                      I`m actually more interested in knowing why my script doesnt work than in getting a working solution.

                                      (The project is small and not very important)

                                      • 16. Re: DropDownList bug ?
                                        nathanbie Level 1

                                        Toft, I've updated your provided code to work with the Flex 4 sdk. It looks like you were mainly running into a namespace issues ( mx:WindowedApplication & mx:Script ).

                                         

                                        App Mxml:

                                         

                                        <?xml version="1.0" encoding="utf-8"?>
                                        <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                                    xmlns:s="library://ns.adobe.com/flex/spark"
                                                                    xmlns:mx="library://ns.adobe.com/flex/halo"
                                                                    width="200"
                                                                    height="280"
                                                                    showStatusBar="false"
                                                                    pageTitle="AlarmClockTV"
                                                                    creationComplete="init();"
                                                                    >
                                        
                                             <fx:Script>
                                                  <![CDATA[
                                                       import components.AlarmClockLine.AlarmClockLine;
                                                       import mx.containers.HBox;
                                                       
                                                       private function init():void
                                                       {
                                                            var acl:AlarmClockLine = new AlarmClockLine();
                                                            acl.x = 0;
                                                            
                                                            var hb:HBox = new HBox();
                                                            
                                                            hb.y = 50;
                                                            hb.x = 0;
                                                            hb.percentWidth = 100;
                                                            
                                                            hb.addChild(acl);
                                                            vb.addChild(hb);
                                                       }
                                                  ]]>
                                             </fx:Script>
                                        
                                             <mx:Canvas id="cContainer"
                                                          width="100%"
                                                          height="100%"
                                                          >
                                                  <mx:VBox id="vb"
                                                             x="0"
                                                             y="72"
                                                             width="100%"
                                                             height="100%"
                                                             horizontalAlign="center"
                                                             verticalGap="15"
                                                             >
                                                  </mx:VBox>
                                             </mx:Canvas>
                                        
                                        </s:WindowedApplication>
                                        
                                         
                                        

                                         

                                         

                                        AlarmClockLine Mxml:

                                         

                                        <?xml version="1.0" encoding="utf-8"?>
                                        <mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                     xmlns:mx="library://ns.adobe.com/flex/halo"
                                                     xmlns:s="library://ns.adobe.com/flex/spark"
                                                     height="20"
                                                     backgroundAlpha="0.0"
                                                     creationComplete="initComp();"
                                                     width="200"
                                                     >
                                        
                                             <fx:Script>
                                                  <![CDATA[
                                                       import mx.collections.ArrayCollection;
                                                       import mx.controls.Alert
                                                       
                                                       private var acChannels:ArrayCollection;
                                                       
                                                       private function initComp():void
                                                       {
                                                            acChannels = new ArrayCollection();
                                                            acChannels.addItem({ label: "One", data: 1 });
                                                            acChannels.addItem({ label: "Two", data: 2 });
                                                            acChannels.addItem({ label: "Tree", data: 3 });
                                                            ddlChannels.dataProvider = acChannels;
                                                            //Alert.show("initComp is working");
                                                       }
                                                  ]]>
                                             </fx:Script>
                                        
                                             <s:DropDownList id="ddlChannels"
                                                                 width="90"
                                                                 justificationRule="auto"
                                                                 >
                                             </s:DropDownList>
                                        </mx:Canvas>
                                        
                                         
                                        

                                         

                                        • 17. Re: DropDownList bug ?
                                          toft Level 1

                                          Holy crap it worked !!

                                           

                                          Thanks nathanbie, very much appreciated !!