Page 1 of 1
Variable PHP link in FLash
Posted: Tue May 10, 2005 11:17 am
by brambulkens
Hi im new here and i got a question about flash.
i need to load a PHP Variable into flash wich need to act like a link.
Part of PHP script:
Code: Select all
$link .= "html/content/column/column". $num_of_files .".html";
echo "<a href=" . $link . ">link to last column</a>";
This acually works.. of course there is a lot of code before this butt that doesnt matter couse thats not the problem
I want de variable $link to load into flash to work als a link under a flash button. But how do i dow that?
i got something like this butt it doesnt work.
Code in first frame of a MC that loops:
Code: Select all
link = new LoadVars();
link.load("e;index.php"e;);
Code under the button:
Code: Select all
on (release) {
getURL(link, "e;content"e;);
}
Butt it doesnt work.
How do i get the PHP variable to load into flash and to work like an actual link? i tried a lot of things but coulnt get it right.
Please help me ....

Posted: Tue May 10, 2005 4:01 pm
by hongco
I know that flash can get data by name-value pairs, so the format should be:
&variable_name=value
so, in your php file
Code: Select all
//instead of using:
//echo "<a href=" . $link . ">link to last column</a>";
// you may have something like
echo "&mylink=$link"; // use ampersand infront of mylink
and in your flash file
Code: Select all
filepath = "e;/path/to/your/php_file/folder/"e;; //path to your php file
linkvar = new LoadVars();
linkvar.onLoad = function (success) {
if(success){
//set your button with $mylink
on (release) {
getURL (linkvar.mylink,"e;_blank"e;);
}
}
}
I never tried it before, will test it myself.
Posted: Tue May 10, 2005 4:28 pm
by brambulkens
Thanx butt i think that the loadvars doesnt belong in the button script..
it has a very good point butt i think the loadvars part need to be in the main time line, within a frame.
Now i get an syntax error if i use it this way.
and you gave the variable filepath no use, at least thats what i think.
maybe something like:
Code: Select all
loadVariablesNum("e;index.php"e;, 0, "e;POST"e;);
??? i dont know butt i think the path to the php file need to be more clear for flash... but i already like ot say thanks for ur effort and help and i hope you will help me more

Posted: Tue May 10, 2005 4:31 pm
by hongco
yah, i don't much about it. just a faint memory from a tutorial.
I found it again for you. YOu might know more from here:
http://www.actionscript.org/tutorials/i ... sh_and_PHP
the website somtimes loads very slow.
Posted: Sat May 14, 2005 6:22 am
by brambulkens
NEW WAY OF WORKING:
Code: Select all
on (release) {
var totalfiles = new LoadVars();
totalfiles.load("e;html/content/totalfiles.txt"e;);
totalfiles.onload = function(){
goto = totalfiles.x};
link = "e;html/content/column/column"e;+goto+"e;.html"e;getURL(goto , "e;content"e;);}
With this script i get variable "X" from file "totalfiles.txt"
X will be putted there later bij PHP but is at this moment equal to "1"
Butt it doenst quet work the way i want ot to. If i look in flash at "List of Variables" of the FlashPlayer i see this:
Code: Select all
Variable _level0.instance8.totalfiles = їobject #1, class 'LoadVars'] {
onload:їfunction 'onload'],
x:"e;1"e; }
Variable _level0.instance8.goto = "e;1"e;
Variable _level0.instance8.link = "e;html/content/column/column1.html"e;
De variables work as you see butt the button still wont take the variable as the link... verry strange. As in mather of fact as i click the button it opens the folder wich contains the index.php. The folder wich contains the path of the variable "link". If i putt it online and click the button, it wont do nothing at all...
What to do about it????