Variable PHP link in FLash

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brambulkens
Forum Newbie
Posts: 3
Joined: Tue May 10, 2005 11:07 am

Variable PHP link in FLash

Post 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(&quote;index.php&quote;);
Code under the button:

Code: Select all

on (release) {
	getURL(link, &quote;content&quote;);
}
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 .... :( :?
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post 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 = &quote;/path/to/your/php_file/folder/&quote;;    //path to your php file
linkvar = new LoadVars();        
linkvar.onLoad = function (success) {
        if(success){
          //set your button with $mylink
          on (release) {
	     getURL (linkvar.mylink,&quote;_blank&quote;);
          } 
        }
}
I never tried it before, will test it myself.
brambulkens
Forum Newbie
Posts: 3
Joined: Tue May 10, 2005 11:07 am

Post 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(&quote;index.php&quote;, 0, &quote;POST&quote;);
??? 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 :D
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post 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.
brambulkens
Forum Newbie
Posts: 3
Joined: Tue May 10, 2005 11:07 am

Post by brambulkens »

NEW WAY OF WORKING:

Code: Select all

on (release) {
var totalfiles = new LoadVars();
totalfiles.load(&quote;html/content/totalfiles.txt&quote;);
totalfiles.onload = function(){
goto = totalfiles.x};
link = &quote;html/content/column/column&quote;+goto+&quote;.html&quote;getURL(goto , &quote;content&quote;);}
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 = &#1111;object #1, class 'LoadVars'] { 
onload:&#1111;function 'onload'],    
x:&quote;1&quote;  }
Variable _level0.instance8.goto = &quote;1&quote;
Variable _level0.instance8.link = &quote;html/content/column/column1.html&quote;
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????
Post Reply