8 Replies Latest reply on Aug 21, 2006 12:33 PM by Ryan_Kellogg

    Please Help - passing a local variable to live content??

    Ryan_Kellogg
      i am trying to solve a problem and i think that i have a solution...i just don't know if its possible...here's the situation:

      - an interactive cd with links to individual URLs; the user clicks a link and is
      taken to a log in page (which is basically just a password input screen)

      - if their log in is successful, they are then directed to the specific page they
      clicked to, from the cd

      my question is this:
      say that from the cd , they click "link2"...is there a way to have flash store a variable (let's call it "link2" as well) in this LOCAL content, that i can then check with an if statement in the LIVE content

      i am thinking that if the login page just has an if statement that looks for that variable ("link2" , "linkX" , etc), and then depending on its name, takes you to the appropriate page (link2.html, etc)

      i just don't exactly know how to pass that variable from local content to a live flash site...can anyone help me wrap my head around this one? thanks for your time
        • 1. Please Help - passing a local variable to live content??
          abeall Level 3
          I would think you just need to send some POST or GET data with your getURL(use F1 reference for details) which get's processed by a serverside script and throws it into Flash, perhaps the safest way is by using FlashVars embed param. So maybe on the CD:

          var link = "link2";
          getURL(' http://myDomain/myLogin.php?link='+link);

          or

          createEmptyMovieClip('packet_mc',getNextHighestDepth());
          packet_mc.link = "link2";
          packet_mc.getURL(' http://myDomain/myLogin.php','POST')

          (getURL using POST will send all variables in the MovieClip that getURL is called on as POST data, so in the above case I make a clean MovieClip with only one variable on it, the link variable)
          • 2. Re: Please Help - passing a local variable to live content??
            abeall Level 3
            BTW, are you using a projector on the CD? If not, be advised that the Flash Player will not allow the user to connect to the internet at all without taking some special measures.
            • 3. Please Help - passing a local variable to live content??
              abeall Level 3
              *edited original post for forum users, newsgroup users will see edit here instead
              • 4. Please Help - passing a local variable to live content??
                Ryan_Kellogg Level 1
                abeall-thx so much for your help; to answer your question...yes it will be a projector file, will i need to make the urls absolute?

                also, the login page is built in flash and just embedded in an html page, so would it work if i did something like this(on the SUBMIT button):

                on(release){
                createEmptyMovieClip('packet_mc',getNextHighestDepth());
                packet_mc.link = "link2";
                packet_mc.getURL('[L=','POST')]http://myDomain/myLogin. html");
                }

                again thank you so much for your help

                • 5. Re: Please Help - passing a local variable to live content??
                  abeall Level 3
                  > yes it will be a projector file, will i need to make the urls absolute?
                  Standard rules apply, so you don't have to make everything absolute, but sure, if you are accessing a different domain than the current location(which is the CD) you'll have to make it absolute.

                  >also, the login page is built in flash and just embedded in an html page, so
                  > would it work if i did something like this(on the SUBMIT button):
                  >
                  > on(release){
                  > createEmptyMovieClip('packet_mc',getNextHighestDepth());
                  > packet_mc.link = "link2";
                  > packet_mc.getURL('[L=','POST')]http://myDomain/myLogin.html");
                  > }

                  Well, that's only part of it. What you really need to do is take the variable that was sent via POST and embed it dynamically into the Flash. The easiest way to pass vairables into Flash is with FlashVars, like this:

                  <param name="FlashVars" value="link=link2" />
                  and in the <object> tag:
                  flashvars="link=link2"

                  The problem is, you want that param to be dynamic. To do that, you can dynamically build the HTML with PHP or ASP. I can't really help you there, though, sorry.
                  • 6. Re: Please Help - passing a local variable to live content??
                    Ryan_Kellogg Level 1
                    ok that is a big help...just a few more pieces...well, i will see what i can dig up on the dynamic html...as far as the flashVARS are concerned...do i just append that line to the on(release) statement we came up with? thanks again
                    • 7. Re: Please Help - passing a local variable to live content??
                      abeall Level 3
                      Not quite. There are actually several different things going on here. You really described them in your first post.

                      1) You need a local variable. That's easy, I assume you know all about using variables and objects in Flash.

                      2) You need to send the variable someplace. Flash is a "blackbox", it doesn't know where it's sending or why, it doesn't have to, it just needs to send it.

                      3) You need to receive the variables, and pass them into a new Flash.

                      To do 2), you use the getURL and POST data like we came up with. That's just the sending part. In fact, if you use the code I provided in your on(release) then your local Flash & code for the CD is actually done, it *will* send the variables wherever you want. But of course, sending doesn't do any good if there's no one to "catch it" and do something useful with it.

                      So to 3) put the vars in a Flash on a web page, you have the biggest part of the challenge. There are a number of ways to try and get variables that are passed to the server to be passed to inside an embedded Flash. You can do this with Javascript, use Flash 8 with ExternalInterface, and various related methods. But one basic and nearly fail proof way to get a variable into Flash is with FlashVars:
                      http://www.google.com/search?q=FlashVars&sourceid=mozilla2&ie=utf-8&oe=utf-8

                      The problem with FlashVars is, you can create a login page that contains flashvars in tghe embed tags, but the point is you somehow need to get the variable which was sent to the server to be put into that FlashVar. To do that, you'll need to use a serverside script like PHP or ASP. Or you might be able to do it with JavaScript somehow, but I wouldn't know. This might be a good place to start looking for ideas:
                      http://www.permadi.com/tutorial/flashVars/index.html
                      • 8. Re: Please Help - passing a local variable to live content??
                        Ryan_Kellogg Level 1
                        abeall...thank you so much for all your help...i posted a few different places and you were the only one who really took the time to help me wrap my head around this...thank you...i don't have all the pieces b/c i am not much for php and asp but you gave me a lot mroe to go on than i had...thanks again