3 Replies Latest reply on Jul 12, 2007 4:27 PM by GordonSmith

    Question/Requestion about ComboBox     

    celebi23 Level 1
      Was wondering if someone could help me with something. I've got a ComboBox on my app. It's for a search box. There are fix different options in the ComboBox, each pointing to a different URL. I originally coded this in Dashcode on Mac OS X but, I'm porting it to AIR using Flex Builder 3. I'm including my code & the code of someone who's been helping me out so far. I'm also including the code for the ComboBox if that'll help. If someone could figure it out (been wracking my brain & still not getting anywhere) that'd be great.

        • 1. Re: Question/Requestion about ComboBox     
          odyssey27 Level 1
          Guess we'd need to know what specific problem you're having. I can't tell if you are presenting code fragments so a more complete example (not your app code, just the code surronding the combobox and how you're accessing/using it would be helpful.
          • 2. Re: Question/Requestion about ComboBox     
            celebi23 Level 1
            ok, odyssey27, here's the code for the main.mxml file. Hopefully that'll give you a better idea as to what I want to accomplish with this app

            • 3. Question/Requestion about ComboBox     
              GordonSmith Level 4
              From your Dashcode, I can see that when you choose, for example, "Manuals" in the ComboBox, the URL you're fetching should end with the additional URL query parameter &type=kmanual. In other words, each item in the ComboBox has an associated "type code" such as "kmanual" for "Manuals". The way this is typically coded is to make your ComboBox's dataProvider be an array of objects with "label" and "data" properties:

              <mx:dataProvider>
              <mx:Object label="All Categories" data=""/>
              <mx:Object label="Technical Articles" data="ktech+OR+klearn"/>
              <mx:Object label="Downloads" data="kbdload"/>
              <mx:Object label="Manuals" data="kmanual"/>
              <mx:Object label="Help" data="khelp"/>
              </mx:dataProvider>

              The combobox automatically displays the "label" property. (You can specify a different property by setting the labelField property.) But when you make a selection, the selectedItem property will be a reference to the entire object, so you can access the "type code" as selectedItem.data:

              public function executeSearch(event:MouseEvent):void
              {
              var url:String = " http://search.info.apple.com/index.html?as_q=" + AppleSearch.text + "&btnG=Search&lr=lang_en";
              var type:String = searchList.selectedItem.data;
              if (type.length > 0)
              url += "&type=" + type;
              var u:URLRequest = new URLRequest(url);
              navigateToURL(u,"_blank");
              }