php vars to flash

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    php vars to flash

    Hi,

    How can i pass a random digit that is created using a php var into flash so i can use it in AS. Once its in AS what would i write so that the digit is show in flash?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Using flashvars.

    Read: http://www.kirupa.com/developer/acti...gvariables.htm

    Although, I'd suggest you use SWFObject to embed your flash and pass variables to the SWF.

    Comment

    • anfetienne
      Contributor
      • Feb 2009
      • 424

      #3
      thanks....i've just read through the blog page and I think it would be best to use SWFObject as well....seems much more safer and secure.....and more compatible with all browsers

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by anfetienne
        thanks....i've just read through the blog page and I think it would be best to use SWFObject as well....seems much more safer and secure.....and more compatible with all browsers
        Sure thing.

        Let me know if you hit any snags.

        - Mark.

        Comment

        • anfetienne
          Contributor
          • Feb 2009
          • 424

          #5
          just a quick question.....wh en passing variables, i see in the swfobjec t they have it assigned to a dynaic text box. what i want is so that the variable is used only in actionscript... .do i have to assign it to a text box or is there a way for this to just be used in actionscript?

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            You don't have to assign anything to anything.

            Say you're passing the flash vars like so:

            Code:
            window.onload = function()
                {
                    var flashvars = {
                        testFlashVar: "Hello from Bytes.com!"
                    };
                        var params = {
                            wmode: "transparent"
                        };
                        var attributes = {};
                        swfobject.embedSWF([...]);
                }
            In your AS, the variable is available by (at root) :
            Code:
            trace( testFlashVar );
            Does this help?

            Comment

            • anfetienne
              Contributor
              • Feb 2009
              • 424

              #7
              that's great.....thank s for that markus

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Originally posted by anfetienne
                that's great.....thank s for that markus
                You're welcome.

                - Mark.

                Comment

                • anfetienne
                  Contributor
                  • Feb 2009
                  • 424

                  #9
                  just to double check if i send a php var to flash using SWFObject

                  say....
                  <?
                  $testVar = "anfetienne ";
                  ?>

                  window.onload = function()
                  {
                  var flashvars = {
                  testFlashVar: "<?PHP print $testVar;?>"
                  };
                  var params = {
                  wmode: "transparen t"
                  };
                  var attributes = {};
                  swfobject.embed SWF([...]);
                  }

                  to be able to use testFlashVar in flash actionscript all i need to do is use

                  trace( testFlashVar ); to bring it in then afterwards i can put testFlashVar anywhere in the actionscript?

                  also should it be......swfobje ct.embedSWF(tes t.swf); or swfobject.embed SWF([test.swf]);?

                  Comment

                  • Markus
                    Recognized Expert Expert
                    • Jun 2007
                    • 6092

                    #10
                    1. Yep, that's correct.

                    2. Check out the documentation for SWFObject to understand how to embed it.

                    Comment

                    Working...