We help IT Professionals succeed at work.
Get Started

Passing combobox var to loaded swf as3

Alex500
Alex500 asked
on
696 Views
Last Modified: 2013-11-11
Hi all, I've been building a world cup quiz. I have a combobox that loads a swf with the questions in. On the first swf the user chooses a country which loads a swf onto the stage which contains the questions. I cant work out how to pass the country name from the combobox to the new swf.

my ComboBox and swf load code is as follows:


package {
      
      
      import flash.events.*;
      import flash.display.*;
      import fl.controls.ComboBox;
      import fl.data.DataProvider;
      import flash.net.URLRequest;
      import flash.display.Loader;
      import flash.events.ProgressEvent;

      
      public class yahoo extends MovieClip {
      
                  private var bg:background_mc = new background_mc();
                  private var goal:goal_mc = new goal_mc();
                  private var soccerStars:soccerStars_mc = new soccerStars_mc();
                  /*private var replayBtn:replayBtn_mc = new replayBtn_mc();*/
                  private      var comboBox:ComboBox = new ComboBox();
      
      
                        public function yahoo() {
                              
                              stage.addChild(bg);
                              bg.x = 300;
                              bg.y = 300;
                              
                              stage.addChild(goal);
                              goal.x = 450;
                              goal.y = 180;
                              
                              stage.addChild(soccerStars);
                              soccerStars.x = 10;
                              soccerStars.y = 10;
                              
                              /*stage.addChild(replayBtn);
                              replayBtn.x = 580;
                              replayBtn.y = 40;
                              replayBtn.addEventListener(MouseEvent.MOUSE_DOWN, replay);*/
                              
                              stage.addChild(comboBox);
                              comboBox.x = 200;
                              comboBox.y = 300;
                              comboBox.dropdownWidth = 200;
                              comboBox.width = 200;
                              comboBox.prompt = "Select a nation";
                              comboBox.dataProvider = new DataProvider (worldcupNations);
                              comboBox.addEventListener(Event.CHANGE, changeHandler);
                              
                              
                        }
                        
                        
                        
                        /*Creates the Array of nations*/
                        var worldcupNations:Array = new Array (
                              {label:"Algeria"},
                              {label:"Argentina"},
                              {label:"Australia"},
                              {label:"Brazil"},
                              {label:"Cameroon"},
                              {label:"Chile"},
                              {label:"Cote d'Ivoire"},
                              {label:"Denmark"},
                              {label:"England"},
                              {label:"France"},
                              {label:"Germany"},
                              {label:"Ghana"},
                              {label:"Greece"},
                              {label:"Honduras"},
                              {label:"Italy"},
                              {label:"Japan"},
                              {label:"Korean DPR"},
                              {label:"Korea Republic"},
                              {label:"Mexico"},
                              {label:"Netherlands"},
                              {label:"Nigeria"},
                              {label:"Paraguay"},
                              {label:"Portugal"},
                              {label:"Serbia"},
                              {label:"Slovakia"},
                              {label:"Slovenia"},
                              {label:"South Africa"},
                              {label:"Spain"},
                              {label:"Switzerland"},
                              {label:"Uraguay"},
                              {label:"USA"}
                              
                                                                                
                        );  
                        
                        
                  
                  function changeHandler (e): void {
                        
                        
                        /*Load in external swf */
                        var loadSwf:Loader = new Loader();
                        var requestSwf:URLRequest = new URLRequest("Quiz/Quiz.swf");
                        loadSwf.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                        loadSwf.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
                        loadSwf.load(requestSwf);
                        
                        
                        
                        /* Add swf to stage */
                        function onCompleteHandler (loadEvent:Event) {
                              
                              stage.addChild(loadEvent.currentTarget.content);
                              
                              
                        }
                        
                        /* Progress tracking*/
                        function onProgressHandler(mProgress:ProgressEvent) {
                              var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
                              trace (percent);
                              
                        }
                        
                  }
      
      }
      
}
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE