I'm trying to set up a website so that I can pipe in page content based from a PHP database. I'm done a little research on the subject and I feel comfortable with most of the implementation details, but I'm missing a step somewhere. I've already got my php page set up and it's spitting out the appropriate data in the correct format, like so: maxPages=142&LeftPage=left page stuff&RightPage=right page stuff I'm also pretty clear on the fact that I need to use the LoadVars class in a manner such as the following: Code: var myLV = new LoadVars(); myLV.onLoad = processVariables; myLV.load("pageContent.php"); function processVariables(success) { if (success) { _root.RightPage = _root.myLV.RightPage; _root.LeftPage = _root.myLV.LeftPage; } } I guess where I'm getting lost is the part where I connect all the front-end pieces together. I have several movie clips with names like "page1", "page2", etc. and they all have just one frame. Each page has a dynamic text box, and I figure somehow it's supposed to know to put the variable text in there somehow, but that's the part I'm not getting. I tried giving my text box an instance name like "rightPage" and putting the above code in the "Actions" code field (or whatever it's called), but I never got anything. What am I missing? Thanks.
What kind of text box is it? Try making it a dynamic text box with the "var" property set to _root.RightPage. Another thing to try would be to give it an instance name and set it directly like _root.movieClipName.instanceName.text = _root.RightPage; Also, you can trace the values that you get back to make sure you're getting data. if (success) { _root.RightPage = _root.myLV.RightPage; trace(_root.RightPage); _root.LeftPage = _root.myLV.LeftPage; }
Okay... I put this little project on hiatus because I never got it to work, but now I'm back. Still nothing. Slowly-D - Are you sure that I can't put spaces in my string? I'm almost certain you can. Otherwise, what I'm trying to do would be impossible, and clearly it's possible because lots of people do it. Rocketeer - How do I set up my text boxes to rendor HTML? I'm willing to send the code to someone if you're willing to look at it. Thanks guys.
In your function that is executed when the variables load are you able to output the data you want to see using trace()? That will tell you if the problem is getting the data or setting the text box.
Actually I'm not getting any trace comments. Here's my current code: Code: var myLV = new LoadVars(); myLV.onLoad = function(success) { if (success) { _root.mypage = _root.myLV.RightPage; trace("success"); trace(_root.mypage); } else { trace("fail"); _root.mypage = "We bombed!" ; } } myLV.load("pageContent.php?q=" + new Date().valueOf() ); The code on the first frame of my Layer, which I have named "Text Box", not on the Text Box itself, which I tried already and got errors. My text box is in it's own frame, and it's Dynamic. It has an instance name of "mypage", and I made it "Multiline". In the Var field I put "_root.mypage". Probably some of that is unnecessary but I've been trying a lot of stuff to get it working.
The myLV object isn't in the _root level. Change _root.mypage = _root.myLV.RightPage; To _root.mypage = myLV.RightPage; or _root.mypage = this.RightPage;
Generally it's a good idea to url encode anything that's passed in that fashion to prevent strange bugs. Here's the PHP manual page for how to do that. http://us3.php.net/urlencode
Dude! You totally rule! I've seriously been trying to get that to work for like 2 weeks! Thanks! I owe you a pizza.