3 Replies Latest reply on Apr 4, 2012 8:51 AM by creacog -

    How to pass Flashvars from a Flash loader to a Flex app?

    Handycam Level 1

      I have a series of Flex apps that I needed to load depending on a user choice. Since the apps rely on  root-level "application.application" variables, I was advised here (by Alex Harui) to use a non-flex SWF as the loader.  So I built one in Flash.


      It works great, my apps run fine.  However, my apps also originally loaded Flash vars from the HTML.  Since they are being loaded now by the Flash SWF, this data is missing (of course) and certaint things fail.


      I have modified the Flash file to get my Flashvars and store them in variables, but how do I get that info into the Flex apps?


      Here's the loader:



      // to hold the flash vars loaded from the html
      var userID:int;
      var cyorID:int;
      var key:int;
      var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
      userID = new int(paramObj.ui);
      cyorID = new int(paramObj.cyor);
      key = new int(paramObj.key);
      pizza_neapolitan.addEventListener(MouseEvent.CLICK, pizzaChoice);
      pizza_sicilian.addEventListener(MouseEvent.CLICK, pizzaChoice);
      pizza_thin.addEventListener(MouseEvent.CLICK, pizzaChoice);
      function pizzaChoice(e:MouseEvent):void
                var filename:String = '/cyor/' + e.currentTarget.name + '.swf';
                var myLoader:Loader = new Loader();
                var myUrl:URLRequest = new URLRequest(filename);