Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get variable from http?

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
adres.html?bla=1

i need to get the variable "bla" from a web adres into flash

i know how to do it with php
<?php $bla = $HTTP_GET_VARS['bla']; ?>

but how o how to do it with flash?

thnx
thomas
 
You need to use JavaScript to add the var to the flash swf

address.html?blah=1

Code:
<html>
  <head>
    <title>
      Flash recieve var
    </title>
    <script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
    <!--
        // This function is replace function

        function sReplace (search, replace, string) {
          while (string.indexOf (search) > -1) {
            pos = string.indexOf (search);
            string = (string.substring (0, pos) + replace +
            string.substring ((pos + search.length), string.length));
          }
          return string;
        }

        // This function reads query string keys and values into arrays

        qStr.keys = new Array ();
        qStr.values = new Array ();

        function qsParse () {
          var query = window.location.search.substring (1);
          var pairs = query.split (&quot;&&quot;);
          for (var i = 0; i < pairs.length; i++) {
            var pos = pairs[i].indexOf ('=');
            if (pos >= 0) {
              var argname = pairs[i].substring (0,pos);
              var value = pairs[i].substring (pos+1);
              qStr.keys[qStr.keys.length] = argname;
              qStr.values[qStr.values.length] = sReplace ('+',' ', unescape (value));
            }
          }
        }

        qsParse ();

        // This function returns the value of a query string key

        function qStr (key) {
          var value = &quot;&quot;;
          for (var i = 0; i < qStr.keys.length; i++) {
            if (qStr.keys[i] == key) {
              value = qStr.values[i];
              break;
            }
          }
          return value;
        }
    //-->
    </script>
  </head>
  <body bgcolor=&quot;#ffffff&quot;>
    <script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
    <!--
        var width  = 100;
        var height = 100;
        var bgclr  = &quot;FFFFFF&quot;;
        var movie  = &quot;movie.swf?blah=&quot; + qStr ('blah');
        document.write (&quot;<OBJECT classid=\&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\&quot; codebase=\&quot;[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\&quot;[/URL] WIDTH=&quot; + width + &quot; HEIGHT=&quot; + height + &quot;> <PARAM NAME=movie VALUE=\&quot;&quot; + movie + &quot;\&quot;> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#&quot; + bgclr + &quot;> <EMBED src=\&quot;&quot; + movie + &quot;\&quot; quality=high bgcolor=#&quot; + bgclr + &quot;  WIDTH=&quot; + width + &quot; HEIGHT=&quot; + height + &quot; TYPE=\&quot;application/x-shockwave-flash\&quot; PLUGINSPAGE=\&quot;[URL unfurl="true"]http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\&quot;></EMBED></OBJECT>&quot;);[/URL]
    //-->
    </script>
  </body>
</html>

The var: 'blah' will then be available in flash in the _root level Regards
David Byng
spider.gif

davidbyng@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top