2 Replies Latest reply on Dec 28, 2007 12:05 PM by Shelady

    Calling A .SWF through a Combo box.

    Shelady Level 1
      Hi,
      I drag a combo box and provide 3 options January, February and March. I want to see 3 different .SWF files in the same page when I choose one of these options. Please help me call the movies through combo box selection. Here is my code.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:ComboBox xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:dataProvider>
      <mx:ArrayCollection>
      <mx:String>January</mx:String>
      <mx:String>February</mx:String>
      <mx:String>March</mx:String>
      </mx:ArrayCollection>
      </mx:dataProvider>
      </mx:ComboBox>
      </mx:Application>

      Thanks
        • 1. Re: Calling A .SWF through a Combo box.
          Garyl Woolworth Level 1
          I would store the filename of the swf within your Combo Box dataProvider and then when it changes load the new swf based upon what they chose. I wrote a sample application that achieves this.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

          <mx:Script>
          <![CDATA[
          import mx.collections.ArrayCollection;

          [Bindable] private var swfDP:ArrayCollection = new ArrayCollection([
          {label:"Choose a Month", data:""},
          {label:"January", data:"january.swf"},
          {label:"February", data:"february.swf"},
          {label:"March", data:"march.swf"}]);

          private function onComboChange(event:Event):void {
          // => Check to see if swf location exists, if it does then load the new swf.
          (event.currentTarget.selectedItem.data != "") ? loader.load(event.currentTarget.selectedItem.data) : "";
          }
          ]]>
          </mx:Script>

          <mx:ComboBox dataProvider="{swfDP}" change="onComboChange(event)" />

          <mx:SWFLoader id="loader" width="300" height="300" />

          </mx:Application>

          You will need to change the filename's to match yours unless they really are named january.swf and what not. Hope this helps.
          • 2. Re: Calling A .SWF through a Combo box.
            Shelady Level 1
            Thanks. It works.