-
how to use variables passed from PHP
Hi I use the following to get variables from a php script which generates something like this
&load1=http://www.domain.com/images/image1.jpg
&load2=http://www.domain.com/images/image2.jpg
&load3=http://www.domain.com/images/image3.jpg
&load4=http://www.domain.com/images/image4.jpg
I can display these variables in a textbox by setting the var=load1 and so forth. But if I want to use the variable load1 inside a
loadMovie(load1);
this has been simplified! I have tried to type in the exact URL to the image which then shows the image in my FLASH movie. But when I enter my variable i.e. load1, it doesnt sho the image???
Pls Help,
Thanks, Mads Andersen
-
Try:
Code:
loadMovie("'" + load1 + "'");
not really sure if that would work though. The gist of what I'm saying is that you would need quotes to read the variable the way you are attempting.
-
Nope
That doesn't work either??? And I even tried to (in PHP) and strip the ".jpg" from the &load1=image1
then
loadMovie("http://www.domain.com/images/" + load1 + ".jpg");
that didnt help me either? But still my textbox does display the correct name of the file???
Last edited by madsandersen; 09-21-2005 at 06:48 PM.
-
Registered User
hi,
You need to load and preload the variables and for this you shoud use the LoadVars Class. Here's a simple example:
code:
// create an empty movie clip:
this.createEmptyMovieClip("my_mc", 1);
// load the variables
var my_lv = new LoadVars();
my_lv.onLoad = function(ok)
{
if (ok) {
// do what you want with the variables, for example:
this.createEmptyMovieClip("my_mc", 1);
// load the image:
my_mc.loadMovie(this.load1);
// see some other variables:
trace('load2 -> ' + this.load2);
trace('load3 -> ' + this.load3);
} else {
trace("an error occurred");
}
};
my_lv.load('myScript.php');
For more details read loading variables.
-
this has been simplified!
what do you mean? what is the string that you end up with?
-
By "simplified" I meant
that I have a whole lot more than simply
loadMovie(load1);
but it does work if I enter "http://www.domain.com/images/image1.jpg" into the loadMovie... simply I meant that all of the surrounding code wasn't added :-)
Mads
-
Ok that didn't work either...
The exact code is below
I have 1 movieClip which is named "images" which I duplicate
-------
loadVariablesNum ("my_script.php", 0, "POST"); // loads vars names load1, load2, load3 etc..
total_images = 10;
posx = 1; // startposition
for(i=1; i<total_images; i++){
images.duplicateMovieClip("image"+i, depth);
this["image"+i]._x = posx;
this["image"+i]._y = 3;
this["image"+i].loadMovie("http://www.domain.dk/art_imagefiles/" + load+i + ".jpg");
posx = posx + 46;
depth = depth + 1;
}
stop();
This does work if I i.e. write:
this["image"+i].loadMovie("http://www.domain.dk/art_imagefiles/imagename.jpg");
strange?
Mads
-
this should work better:
Code:
this["image"+i].loadMovie("http://www.domain.dk/art_imagefiles/" + _level0["load" + i] + ".jpg");
-
Nope
still not woking? And I see the variable values inside textboxes named load1, load2 etc...
ARGH!
-
I get the following output from my PHP script
&load1=Albrecht_007_1&load2=Troest_004_1&load3=Tro est_003_1&load4=Albrecht_001_1
which is the names of the images, without the URL and the ".jpg"
-
go blues !
ah, thatll be the URL your using dude
this["image"+i].loadMovie("http://www.domain.dk/art_imagefiles/" + http://www.domain.com/images/image1.jpg+ ".jpg");
dosent make sense hey ! you are inserting an entire url into the url, just load the url which is in the var
this["image"+i].loadMovie(load+i);
Last edited by audas; 09-22-2005 at 12:07 PM.
peace.
-
go blues !
yeah, oohhh yeahhh, ahhhh yeahhhh, ohhh baby ! your so hot
-
Nope...
I did strip the URL down to only contain the imagename... I.e. load1=Imagename1
and not
load1="http://www.domain.com/art_imagefiles/Imagename1.jpg"
Because I tried that already :-)
Mads
PS: that's just in my first post I wrote the eample, but someone told me that loadMovie espects something like ("URL"+something)....
-
go blues !
no man just load it straight in, the image name will do,you dont need an absolute url, relative is fine.....
-
It's Not Working Aaaargh!!!
I've tried to make my variables
1:
------
load1="http://www.domain.dk/images/image1.jpg"
and
loadMovie(load1);
------
2:
------
load1="image1"
and
loadMovie(http://www.domain.dk/images/"+load1+".jpg");
------
3:
------
load1="image1.jpg"
and
loadMovie(http://www.domain.dk/images/"+load1);
--
But It doest work? And still my textbo diplays the correct stuff?
I.e. a textbo named load1 will display the load1 variable from php???
HELP
-
go blues !
run a trace action on the load+i and see what it says, try replaceing load+i with _root.load+i.
I think you will find that if you just use the LoadVars class as suggested by nunomira you will solve all your problems, this is what it is for and it works a treat.
-
I tried that already
And nothing?
How do I run the trace action on load+i?
-
This is probably not the solution, but i think your loadmovie statement lacks a parameter:
Code:
loadMovie(http://www.domain.dk/images/"+load1+".jpg");
if you're trying to load your jpeg onto level 1 say, then this should read:
Code:
loadMovie(http://www.domain.dk/images/"+load1+".jpg",1);
if you're trying to load your jpeg into a movieclip:
Code:
yourMovieClipInstanceName.loadMovie(http://www.domain.dk/images/"+load1+".jpg");
-
go blues !
-
the thing is
that my movie does in fact load a jpg with the following statement
this["image"+i].loadMovie("http://www.domain.com/images/image1.jpg");
but I have several variables called load1, load2, load3 etc.. right.
they contain the name of the image, but without the ".jpg".
so I want to use the loaded vars to do the following
this["image"+i].loadMovie("http://www.domain.com/images/"+load1+".jpg");
but however this deosn't shoa an image? And I've checked my vars if they are passed on to flash, and they are because I created 3 dynamic textboxes with the vars load1, load2 and load3, and they disply the imagename witout porblems?
Mads
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
|