Hi, I have a bit of a problem with pulling variables from PHP. I have featured item i want to show in my flash movie. So i set my php variable as so: item_id = 1 and i want it to load a movie that corresponds to that item so i named it: 1.jpg Only thing is when i load the variables from the PHP script they don't work in the "loadMovie" command. The variables are there they just don't seem to work. My question is do I need to make them Global Variables for them to work? and if so how do i go about making them global? I actually posted a similar question about a month ago but didn't get an answer, and got busy with other things. And now i can find the thread. Any help you can give me i would greatly appreciate. thanks.
something like (MX) - sv = new LoadVars(); sv.test = "send variables"; sv.ing = "to php"; lv = new LoadVars(); lv.onLoad = function(){ toLoad = lv.item_id; trace(toLoad); // should output - 1 yourMovieClip.loadMovie(toLoad+".jpg); // 1.jpg must be non-progressive format }; sv.sendAndLoad("the.php", lv, "POST"); - this should work :) good luck,
couldn't get it to work... I am assuming the instance of "the,php" is the only place i tell the clip where to get the php variables? I am using Flash MX and not MX 2004 could that be the factor? I can't even get the Trace to work now. Thanks for all the help. Sorry I didn't respond quicker but i am juggling several projects at one time.
Try this.... (assuming it is variable item_id and on the _root timeline). The variables should load in fine. Say you loaded them into _level0. The end line in your PHP should be: Print "item_id=1"; loadVariablesNum("your.php",0); //This brings in the variable item_id which will be equal to 1 jpgLoad = eval (item_id add ".jpg"); //Convert the variable value of 1 to a statement to load in relevant jpg then to load the image into your target movieclip... yourTargetMovieClip.loadMovie(jpgLoad); //jpgLoad should equal 1.jpg Dunno if this helps!?
already had it at Print "item_id=1"; still no improvement. Like i said i can see the variable, it just doesn't seem to work when i try to add .jpg. it freaks out. I even change it so the variable in php is the path for the image, but that still doesn't work. Does it have to be a global variable to work?
Don't see what you're looking for? Try a search.
|