2 Replies Latest reply on May 17, 2007 11:49 PM by Newsgroup_User

    Passing parameter from HTML

    BobAchgill Level 1
      I would like to know how to pass a parameter from HTML to a variable in my Action Script. Can you point me to an example that shows how to do this?

      Bob
        • 1. Re: Passing parameter from HTML
          barryels
          Hi BobAchgill,

          In your html document:
          <object ...>
          <param ... />
          <param name="movie" value="index.swf?sectionId=0" />
          <embed src="index.swf?sectionId=0" ... />
          </object>

          In your Flash document:
          var urlOrig = this._url;
          var urlParam = urlOrig.substring(urlOrig.lastIndexOf('=') + 1, urlOrig.length);
          trace(urlParam);
          }
          • 2. Re: Passing parameter from HTML
            Level 7
            you have to se JavaScript for that.

            Use this script on html page inside head tag

            <script language ="javascript">
            function getFlashMovieObject(movieName)
            {
            if (window.document[movieName])
            {
            return window.document[movieName];
            }
            if (navigator.appName.indexOf("Microsoft Internet")==-1)
            {
            if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName];
            }
            else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
            {
            return document.getElementById(movieName);
            }
            }

            function SendDataToFlashMovie()
            {

            var flashMovie=getFlashMovieObject("myFlashMovie");
            alert('message '+document.controller.Data.value)
            flashMovie.SetVariable("message", document.controller.Data.value);
            flashMovie.SetVariable("message", document.controller.Data.value);
            }

            </script>

            Use this inside body tag

            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
            codebase="" id="myFlashMovie" width=550 height=250>
            <param name=movie value="flash.swf">
            <embed play=false swliveconnect="true" name="myFlashMovie"
            src="flash.swf" quality=high bgcolor=#FFFFFF
            width=550 height=250 type="application/x-shockwave-flash" >
            </embed >
            </object >
            <form name="controller" method="POST">
            Form Data: <input type="text" name="Data" size="20" value="Enter message">
            <input type="button" value="Send Data" name="SendData"
            onClick="SendDataToFlashMovie();">
            </form>

            This will send data u type in text box to flash.
            The flash u create must have a textbox with var set to message on first
            fame.



            "BobAchgill" <webforumsuser@macromedia.com> wrote in message
            news:f2jgv0$6bu$1@forums.macromedia.com...
            >I would like to know how to pass a parameter from HTML to a variable in my
            >Action Script. Can you point me to an example that shows how to do this?
            >
            > Bob