3 Replies Latest reply on May 23, 2006 9:35 PM by Newsgroup_User

    Need to pass SWF variable *to* HTML

    tdave365
      Hi all, brand new to Flash and I'm being employed to work with a previously-written Flash template. In this template there is a search box. My goal is to get whatever someone puts in that little white search box to my Coldfusion page for further processing. I want this because I know nothing about Flash (yet) and want the variable I need to work with to leave Flash as quickly possible so that I can use it in Coldfusion where I am comfortable on a deadline.

      Here is the code I have that at least produces a promising URL in the browser. After much Googlin' I managed to put this together:

      on (release) {
      Search = this.SomeName.Search; <--- THIS SHOULD BE MY SEARCH VARIABLE
      getURL(" http://www.test.com/web/search.cfm","_top","GET");
      }

      In the browser URL, this actually produces:

      http://www.test.com/web/search.cfm?Search=

      ...which seems promising. But notice, the SEARCH variable is blank.

      I need it so that SEARCH comes back equal to whatever I put in that little white search box.

      So, for example, I need it to come out like this (if I were searching for the word 'Cats'):

      http://www.test.com/web/search.cfm?Search=Cats

      Once it's there it's elementary for me to grab from the URL and work with it in Coldfusion.

      I've tried everything. Google is rife with people trying to pass variable *to* SWF from HTML, but not the other way around. At least that I can tell.

      Anyone have any ideas? Thanks!

      Dave
        • 1. Re: Need to pass SWF variable *to* HTML
          abeall Level 3
          'this.SomeName.Search' must be replaced by the correct path to your search box. Try "insert target path" in the AS editor and see if you can find your input text. You have to/want to give the textbox an instance name, as well as whatever MovieClip it is inside, if any.

          Also, you don't really want to attach the textbox as the query, you want the textbox content. To access a dynamic textfields content, you can use the .text property.

          So, assuming both the button and the textfield reside on the _root timeline(not inside any other movieclips), and you've given the textfield an instance name of "search_txt", this would work:

          on (release) {
          Search = search_txt.text;
          getURL(" http://www.test.com/web/search.cfm","_top","GET");
          }
          • 2. Re: Need to pass SWF variable *to* HTML
            tdave365 Level 1
            That turned out to be the million dollar answer. I was coming back to report it when I read your explanation which reads verbatim to what the issue was and how to resolve it. I didn't know there was a tool to help establish a path within Flash, though, so that's cool.

            My Coldfusion page is now happily processing search requests from this Flash thing.

            What I was (and still am really) failing to understand as a newbie is how the various parts of a flash project communicate. Layers? Timelines? Puh-lease. I struggle with Javascript and never even touched C, both of which are the quasi-syntax of Flash Actionscript.

            Thanks for the reply! There are a few others roaming the net looking for this same answer so I hope this exchange winds up in Google soon.

            Just to be thorough in this thread, here's how the final output looks on my end now (true URL disguised to protect the innocently developing):

            • 3. Re: Need to pass SWF variable *to* HTML
              Level 7
              Just to throw it in, you can also use the LoadVars class and
              LoadVars.sendAndLoad method to communicate with Cold Fusion. It might
              seem more complicated to a non-actionscripter at first, but it is more
              robust than getURL -- you can send many name/value pairs (variables)
              easily, you can catch errors and receive custom <cfoutput> from your cfm
              apps. For example, check out this tutorial (there are other examples
              out there, too):

              http://www.adobe.com/support/flash/applications/creating_forms/creating_forms03.html


              tdave365 wrote:

              > on (release) {
              > Search = _parent.SomeName.text;
              > getURL(" http://www.test.com/web/search.cfm","_top","GET");
              > }
              >