We help IT Professionals succeed at work.
Get Started

Passing combobox var to loaded swf as3

Alex500 asked
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() {
                              bg.x = 300;
                              bg.y = 300;
                              goal.x = 450;
                              goal.y = 180;
                              soccerStars.x = 10;
                              soccerStars.y = 10;
                              replayBtn.x = 580;
                              replayBtn.y = 40;
                              replayBtn.addEventListener(MouseEvent.MOUSE_DOWN, replay);*/
                              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:"Cote d'Ivoire"},
                              {label:"Korean DPR"},
                              {label:"Korea Republic"},
                              {label:"South Africa"},
                  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);
                        /* Add swf to stage */
                        function onCompleteHandler (loadEvent:Event) {
                        /* Progress tracking*/
                        function onProgressHandler(mProgress:ProgressEvent) {
                              var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
                              trace (percent);
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