PDA

View Full Version : php and loadVars to pull a variable from one swf to another


AndersStudio
10-30-2006, 06:53 PM
Hi.

I have a .swf that pulls a random testimonial from a database. I am programming a 'read more' link in this .swf. The link should pass the id of that random testimonial to a new .swf file.

on(press){
getURL("http://directory/testimonials_af.php?tid="+link, "POST");
}

testimonials_af.php contains another .swf that needs to retrieve the variable (tid) and load all the testimonials from the database, but show the one that was selected.

However, I have tried several loadVars functions to get this id and place into a variable in flash, but it doesn't seem to work.

I even tried to write the flashvars object in the php like this:

<? $tid = $_GET['tid']; ?>
<script type="text/javascript">
AC_FL_RunContent("classid","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
"codebase","testimonials_af",
"width","600",
"height","300",
"id","single",
"movie","testimonials_af",
"quality","high",
"scale","exactfit",
"wmode","transparent",
"flashvars","tid=<? print("$tid"); ?>",
"bgcolor","#ffffff");
</script>


myVars = new LoadVars();
myVars.load("http://directory/testimonials_af.php", "GET");
_global.id = myVars.tid;

What am I doing wrong?

Cota
10-30-2006, 07:46 PM
if you're running it locally and you dont have apache installed and running, your PHP wont run. Secondly, how is this set up, are the swf's in the same page, does one load the other..?

peptobismol
11-01-2006, 07:24 AM
the flashVars should would. You don't need
----
myVars = new LoadVars();
myVars.load("http://directory/testimonials_af.php", "GET");
_global.id = myVars.tid;
---

flashVars will dump the variable & values on your root...

Flash Gordon
11-01-2006, 07:42 AM
getURL("http://directory/testimonials_af.php?tid="+link, "POST");


getURL(url [, window [, "variables"]])

Parameters
url The URL from which to obtain the document.

window An optional parameter specifying the window or HTML frame that the document should load into. You can enter the name of a specific window or choose from the following reserved target names:

_self specifies the current frame in the current window.
_blank specifies a new window.
_parent specifies the parent of the current frame.
_top specifies the top-level frame in the current window.

variables A GET or POST method for sending variables. If there are no variables, omit this parameter. The GET method appends the variables to the end of the URL, and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for sending long strings of variables.

Returns
Nothing.


k