all groups > flash actionscript > december 2005 >
You're in the

flash actionscript

group:

PHP LoadVars


PHP LoadVars eggtooth
12/14/2005 10:39:31 PM
flash actionscript: I am attempting to load a variable into Flash from the php page the swf resides
on. I can get a hard coded variable to work just fine, but when I try and pass
a dynamic variable to the PHP page, it won't load. Here is the code I am using
in Flash...

// function to load text from external file
loadText = new LoadVars();
loadText.load("videoTest.php");
//creating the loadVarsText function
loadText.onLoad = function(success) {

if (success) {
_root.movie.myText.text = this.text1;}
else _root.movie.myText.text = "The PHP did not load";
};

On the PHP page, it is just a simple echo or print statement...and it works
hard-coded. Any advice would be herlpful.
Thanks!

Re: PHP LoadVars NSurveyor
12/14/2005 11:03:40 PM
Re: PHP LoadVars eggtooth
12/14/2005 11:16:00 PM
The problem (I think) is in the fact that I am trying to pass a variable from
one page to the page with the swf. When I do this, it seems like the page
finishes loading the swf before the PHP variable is passed to it.

When I execute a query and get the variable from mySQL, it works fine (because
it is there when the swf loads maybe?). But when I try and get it from another
page (based on user input) it doesn't load anything. Am I being clear? Does
this make sense?
Chris

Re: PHP LoadVars NSurveyor
12/14/2005 11:25:57 PM
Re: PHP LoadVars NSurveyor
12/14/2005 11:30:36 PM
Is this correct?

You have a php file with a querystring variable, ex: myphp.php?text1=34 and
you have an swf on that page and you are trying to get that text1 variable into
flash? If so, the way you are doing it won't work. You need to either use
FlashVars in the HTML or add the variables as a quertystring at the end of your
swf file in the EMBED tag in your HTML code. You could do this dynamically
using php to loop through the querystring variables and create the correct code
for your swf. (However, my php knowledge is limited).

And then in your swf, you can find the variable in the _root, for example:
_root.text1
Re: PHP LoadVars eggtooth
12/14/2005 11:34:07 PM
Sorry. Let me start from the beginning...

(1) A user makes a choice on page1.php
(2) That variable gets passed to page2.php
(3) My swf resides on page2.php. It should load the chosen variable into the
swf text field, but it doesn't.
(4) If I skip the above process, and receive the variable directly from a
mySQL database on page2.php, it loads just fine. Only, I don't want to do this.
(5) The variable must be passed from page1 to page2 based on user input. This
is what I can't get to work.

Thanks for your patience and your help!
Chris

Re: PHP LoadVars eggtooth
12/14/2005 11:46:02 PM
Re: PHP LoadVars Mark Ribau
12/15/2005 9:58:13 AM
Try passing the variable that is arriving on the URL from page1 to page2
into the SWF like this:

in your embed statement where you specify the path to the SWF, add the
query to the swf. i.e. the old path is:

"./myswf.swf"

new path is:

"./myswf.swf?<?php echo $myvar ?>"

[quoted text, click to view]


--
<font face="trebuchet ms">
Mark Ribau
Lead Windows Developer | <a href="www.redbugtech.com/blogs/mark.php">My
Tech Blog</a>
<a href="http://www.redbugtech.com">Redbug Technologies, Inc.</a> -
www.redbugtech.com
AddThis Social Bookmark Button