6 Replies Latest reply on Aug 11, 2007 3:53 PM by Henk2

    Using flashVars inside SWF files..

    onlysport
      Now I have used flash vars before and it works great.. This time its a little trickier..

      I'm trying to have one base SWF contain two child SWFs..
      The two child SWFs are graphs and are the same SWF with a different flashVar tag specifying where to get the data from..

      EG:
      Base: base.swf includes 2 child.swfs
      #1. "child.swf?file=file1.xml"
      #2. "child.swf?file=file2.xml"

      Now I'm trying to load these into base.swf using an Image tag.. This works great.. The problem I am having is that the child.swfs are not receiving the "file=xxx.xml" flashVar tag and are failing to a default location.. However when used with plain HTML wrappers with flashVars, the child.swf works perfectly..

      Help for getting flashVars working within an imported SWF??
        • 1. Re: Using flashVars inside SWF files..
          ntsiii Level 3
          This is working for me, though I am using SWFLoader, not Image, but they are essentially the same.

          Are you building the url dynamically, then setting the image.source?

          Tracy
          • 2. Re: Using flashVars inside SWF files..
            onlysport Level 1
            I have tried a few ways.. But not using source..

            My examples are below..

            Can you please post a code example of how you got it to work?


            Image.load
            [code]
            var myURL:String = "./graph.swf?file=data.php";
            Image.load(myURL);
            [/code]

            I have tried using Loader();
            [code]
            var myURL:String = "./graph.swf?file=data.php";
            var Req:URLRequest = new URLRequest(myURL);
            var picLoader:Loader = new Loader();
            picLoader.load(Req);
            [/code]

            Loader with requestHeaders
            [code]
            var myURL:String = "./graph.swf";
            var Req:URLRequest = new URLRequest(myURL);

            Req.requestHeaders = new Array(
            new URLRequestHeader("file", "data.php"))

            var picLoader:Loader = new Loader();
            picLoader.load(Req);
            [/code]

            Loader with URLVariables
            [code]
            var myURL:String = "./graph.swf";
            var Req:URLRequest = new URLRequest(myURL);
            var rand:URLVariables = new URLVariables();
            rand.file = "data.php";
            Req.data = rand;
            [/code]
            • 3. Re: Using flashVars inside SWF files..
              ntsiii Level 3
              In the mxml:
              <mx:SWFLoader id="ldMain" progress="showProgress(event)" width="100%" height="100%" complete="onCompleteAppLoader(event)"/>

              In AS, I build the url:
              sUrl = _sMIPAppUrl + sMenuAction + "&dataSourceUrl=" + _sDataSourceUrl + "&appConfigEditPath=" + _sAppConfigEditPath;

              Set the source:
              ldMain.source = sUrl;

              And in the loaded SWF:
              private function onApplicationComplete(oEvent:Event):void
              {
              var sAppId:String = app.parameters.appid;
              _sDataSourceUrl = app.parameters.dataSourceUrl;
              _sAppConfigEditPath = app.parameters.appConfigEditPath;

              Tracy
              • 4. Re: Using flashVars inside SWF files..
                onlysport Level 1
                I have yet to try this yet, but thank you for your help so far!

                Once I get a chance I'll give it a shot to see if I can get the results I need and let you know.

                Thanks
                • 5. Re: Using flashVars inside SWF files..
                  onlysport Level 1
                  Unfortunately this didn't work for me :-(

                  mxml:
                  [code]
                  <mx:Panel title="Test" width="100%" height="100%">
                  <mx:SWFLoader id="test" width="100%" height="100%"/>
                  </mx:Panel>
                  [/code]

                  load function:
                  [code]
                  var myURL:String = "./graph.swf?file=data.php";
                  this.test.source = myURL;
                  [/code]

                  graph.swf init:
                  [code]
                  if (Application.application.parameters.file is String)
                  {this.updateFile = String(Application.application.parameters.file);}
                  mx.controls.Alert.show(this.updateFile);
                  getUpdate();
                  [/code]

                  Alert shows "null" or "undefined" depending on "String(var)" or "var as String"..

                  This is really starting to get annoying..

                  Any more suggestions??
                  • 6. Re: Using flashVars inside SWF files..
                    Henk2
                    Same problem here.

                    Parameters passed with the URL (eg, "graph.swf?file=data.php") from a Flex app using SWFLoader, are not accessible in the loaded SWF under Application.application.parameters.

                    The child SWF loads with the above example, but the query string seems to be ignored.

                    Have you ever got this to work?