2 Replies Latest reply on Jan 19, 2007 4:11 PM by dotcomguy

    Loading External SWF and setting variables

    dotcomguy
      Hello Everyone.

      I'm sure you are all a where of the FlashVars attribute for Flash embeds which holds variables for SWF's when they are
      rendered. I'm attempting to load an External SWF dynamically from within my own SWF and need to provide it with the values
      normally stored in the FlashVars. For the example below I wait until the External SWF is completely loaded using the
      onLoadInit event from moviecliploader and then i attempt to set the required variables that the loaded SWF needs. This works
      great in test and debug mode (ie. Test Movie and Debug Movie from the Control menu), but when i publish my FLA to SWF and run the SWF the variables will NOT get set in the loaded External SWF. From my readings ive people have mentioned that the player is only able to access Methods of an External SWF. If this is the case then how do they expect people to set the FlashVars of dynamically loaded SWFs? I investigated the loadVariables procedure as well and had the same results in test mode and was wasn't reliable because of timing issues.

      The sample source is below... if anyone has any ideas or has come across this issue before, I would really appreciate some insight.

      Thank you in advance for your time.

      var loader_mc:MovieClipLoader = new MovieClipLoader();
      var mclListener:Object = new Object();
      loader_mc.addListener(mclListener);

      mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number) {
      // DO NOTHING
      }

      mclListener.onLoadComplete = function(target_mc:MovieClip) {
      // DO NOTHING
      }

      mclListener.onLoadInit = function(target_mc:MovieClip) {

      // WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
      target_mc._root.param1 = "value1";

      // WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
      _level0.container_mc.param1 = "value1";

      }

      this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
      container_mc._lockroot = true;
      loader_mc.loadClip("somecoolflash.swf", container_mc);