load vars from a php file
Hi all
I'm wanting to load a variable from a php file and I've found heaps of code on this but I can't seem to work it out to do what I need.
I think it's the "LoadVars();" actionscript I need to understand.
hear is the variable in the php file:
PHP Code:
<?php
$head = $_GET [ 'head' ];
?>
The head is set from an html link.
and it's hear where I need to get the $head variable into flash and then do the following:
if $head = 1 then gotoAndStop("lable_1");
if $head = 2 then gotoAndStop("lable_2");
if $head = 3 then gotoAndStop("lable_3");
And so on and so on......
Any ideas
Cheers
Chris
Senior Mender
PHP
echo "&head=" . $_GET['head'];
myLoader = new LoadVars();
myLoader.onLoad = function()
{
trace(head)
}
Senior Mender
Oups
PHP
echo "&head=" . $_GET['head'];
Flash
myLoader = new LoadVars();
myLoader.onLoad = function()
{
trace(this.head)
}
This doesn't seem to work....any ideas.
code:
myLoader.load("site.php");
myLoader = new LoadVars();
myLoader.onLoad = function()
{
trace(this.head)
}
whichlable = this.head
if (whichlable = "1") {
gotoAndStop("lable_1");
}
if (whichlable = "2") {
gotoAndStop("lable_2");
}
Cheers
Chris
Last edited by cybercampbell; 08-20-2004 at 11:40 AM .
Senior Mender
Use that
myLoader = new LoadVars();
myLoader.onLoad = function()
{
this._parent.gotoAndStop("lable_" + this.head);
}
myCaller.sendAndLoad ("site.php", myCaller, "POST");
Thanks mate
I have decided to rename my lables.
What was the code that you previously posted were I could specify the lable names.
Thanks Chris
Senior Mender
myLoader = new LoadVars();
myLoader.onLoad = function()
{
if(this.head == "1")
{
this._parent.gotoAndStop("label_1");
}
else(this.head == "2")
{
this._parent.gotoAndStop("label_2");
}
}
myCaller.sendAndLoad ("site.php", myCaller, "POST");
Ok...I've done that.
But it 's not working so clearly i'm doing something wrong.
If the label "lable_1" is in a movie clip called "nav", should I put extra code in to tell it to go there?
Where should I place this code....in the first frame or in the movie clip where the labels are?
Thanks for your help
Chris
Senior Mender
myLoader = new LoadVars();
myLoader.onLoad = function()
{
if(this.head == "1")
{
this._parent.nav.gotoAndStop("label_1");
}
else(this.head == "2")
{
this._parent.nav.gotoAndStop("label_2");
}
}
myCaller.sendAndLoad ("site.php", myCaller, "POST");
//////
myLoader is an object that you create into the movie that hold the timeline where you put the code. In your case i believe its on the _root of the movie (main timeline). The 'nav' movie is also, i believe, into your main timeline.
Since the 'onLoad' event is in myLoader you use this._parent to refer to the main timeline and then you put .nav to refer to your 'nav' movie.
Make sure that the movie as the instance name 'nav'. The name in the library is only for developement reference but as no instance on actionscript.
Senior Mender
But it may not work also because i made a mystake ..... Sory!
myLoader = new LoadVars();
myLoader.onLoad = function()
{
if(this.head == "1")
{
this._parent.nav.gotoAndStop("label_1");
}
else(this.head == "2")
{
this._parent.nav.gotoAndStop("label_2");
}
}
myLoader.sendAndLoad ("site.php", myLoader, "POST");
Senior Mender
there is what should work if your php return 1 or 2 as a string
Thanks mate...I'll try it now and I'll let you know how I go.
Cheers
Chris
maybe I'm not setting the variable corectly.
could you please check this for me.
I changed this line:
myLoader.sendAndLoad ("test.php", myLoader, "POST");
for the test.php
also I changed a stop(): to a stop(); in the nav movie clip.
you'll have to take of the .txt at the end of the file I uploaded
Thanks for your help.
Chris
Attached Files
Senior Mender
the page you send me should be call index.html and you should have another file name test.php wich contain only the php
is there any way of flash grabing the variable from the page it's embeded in?
thanks again for all you help
Chris
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width