17 Replies Latest reply on Jul 25, 2008 6:38 PM by kglad

    FlashVars

    Catflea
      I have posted elsewhere but to no avail... trying to pass an image name through FlashVars from a php request into a .swf so that the image will load on runtime... anybody ever heard of this... can it be done?

        • 1. Re: FlashVars
          kglad Adobe Community Professional & MVP
          the php is generating the html page that embeds the swf?
          • 2. Re: FlashVars
            Catflea Level 1
            The swf is loaded in a standard .php page which calls the variable from SQL and places it in the FlashVars param... I have created two dynamic text boxes that imports the text no problems... however I want to import the name of an image that then calls the image from the server and loads it into a movie clip, or call the image directly so that I can work with it on the stage.

            Basically the user of the movie selects an image and text that is placed in a database under a unique ID... this ID then calls all the relevent info out of the database and places it on the stage (including the image).

            The FlashVars is the problem as I cannot get the image loaded into the movie... however I can get the source code of the php to load the image name correctly... ie <param name="FlashVars" Value="message1=Hello World&message2=Hello Catflea&image=hello.jpg" /> but cannot get 'hello.jpg' to load into the movie.

            I hope I have explained this correctly and that you can understand my wafflings. Any help would be much appreciated.
            • 3. Re: FlashVars
              kglad Adobe Community Professional & MVP
              show the code that embeds your swf file using the attach code option in this forum.
              • 4. Re: FlashVars
                Catflea Level 1
                Attached code
                • 5. Re: FlashVars
                  kglad Adobe Community Professional & MVP
                  you have more code than that. show the relevant html code that embeds your swf including your begin and end html tags. the code you showed wouldn't embed your swf.
                  • 6. Re: FlashVars
                    Catflea Level 1
                    This code drags the info out of the database and can get the two dynamic text fields to import the variables... it is just the image that I can not import/work on the stage with.
                    • 7. Re: FlashVars
                      kglad Adobe Community Professional & MVP
                      are you verifying the $row['imagename'] returns what you expect?
                      • 8. FlashVars
                        Catflea Level 1
                        When you process the page the param values return as

                        VALUE="message=this is the caption&from=somebody&image=theimagename.jpg" />

                        which 'message' and 'from' will display in their respective dynamic text boxes... the image (called here) theimagename.jpg is declared but not in the swf.

                        Basically I am getting stuck on the code to bring in the image and to display it on the page.

                        ------------

                        Do you think I am doing this correctly or is there any other way I can bring these variables in? Do you think I could bring these variables in through the url method better? Or would I come up with the same problems I am having now with the image not loading into the swf?

                        BTW - I am very grateful for your help.
                        • 9. Re: FlashVars
                          kglad Adobe Community Professional & MVP
                          there's no reason to change methods. you already have this one (almost) working. there's just something that doesn't make sense.

                          1. how are you verifying that

                          image=theimagename.jpg

                          is returned by your php script?

                          2. how are you checking the value of image in your swf?
                          • 10. Re: FlashVars
                            Catflea Level 1
                            This is where I fall down... Although I have been using flash for over seven/eight years I have always been on the animation side of the art... coding has always been my downfall...

                            I have been trying to load the image through loadMovie() but to no avail as I cannot declare the var to use in the MC... your much needed experience will be valuable...

                            I get an error message relating to unexpected ; ' " etc...
                            • 11. Re: FlashVars
                              kglad Adobe Community Professional & MVP
                              1. create a javascript function:

                              function alertF(s){
                              alert(image);
                              }

                              and call

                              alertF($row['imagename'])

                              to verify that your php script is returning the correct value

                              2. in your swf, use:

                              var tf:TextField=new TextField();
                              addChild(tf);
                              // position tf someplace where you can see it.
                              tf.text = root.loaderInfo.parameters.image;

                              what results?
                              • 12. Re: FlashVars
                                Catflea Level 1
                                Offline last night... before I say anything I would like to say thank you for the help you are offering...

                                I know where the actionscript goes, but can you give me a hint as to where the Javascript slips in? Except for snippets off the net I have never touched Java...
                                • 13. Re: FlashVars
                                  kglad Adobe Community Professional & MVP
                                  your javascript function could be placed between your <head> and </head> tags:
                                  .
                                  .
                                  <script language="javascript">
                                  function alertF(s){
                                  alert(s);
                                  }
                                  </script>
                                  </head>


                                  and the function call could be placed after your body tag:

                                  <body>
                                  <script language="javascript">
                                  alertF($row['imagename'])
                                  }
                                  </script>
                                  .
                                  .
                                  • 14. Re: FlashVars
                                    Catflea Level 1
                                    Hello Kglad...

                                    I inserted the code and it returned a value of...
                                    [object Object] - within the square brackets, but no image...

                                    The php page still returns all the variables need so no change on that... I messed with the 's', changing it to the var name and the php name of 'imagename' but to no avail...

                                    Any further thoughts?
                                    • 15. Re: FlashVars
                                      kglad Adobe Community Professional & MVP
                                      if the alert showed [object Object], $row['imagename'] isn't returning a string.
                                      • 16. Re: FlashVars
                                        Catflea Level 1
                                        Hello kglad,

                                        Thank you for the help given... we have changed direction a little and have sussed the answer that we needed.

                                        Once again thank you.
                                        Catflea
                                        • 17. Re: FlashVars
                                          kglad Adobe Community Professional & MVP
                                          you're welcome.