1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Any Flash guys able to offer some help?

Discussion in 'BBS Hangout' started by DarkHorse, Dec 5, 2005.

Tags:
  1. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    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.
     
  2. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    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;
    }
     
    #2 DrLudicrous, Dec 5, 2005
    Last edited: Dec 5, 2005
  3. Rocketeer

    Rocketeer Member

    Joined:
    Jun 19, 1999
    Messages:
    3,189
    Likes Received:
    1,628
    Make sure that all of your text boxes are set so they render the text as HTML.
     
  4. SwoLy-D

    SwoLy-D Member

    Joined:
    Jul 20, 2001
    Messages:
    37,618
    Likes Received:
    1,456
    Dark, you can't have any spaces on your query string. Or are you just showing us an example?
     
  5. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    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.
     
  6. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    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.
     
  7. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    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.
     
  8. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
  9. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    Awesome. Check your email.

    Thank you.

    :eek:
     
  10. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    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;
     
  11. DrLudicrous

    DrLudicrous Member

    Joined:
    May 9, 2002
    Messages:
    3,936
    Likes Received:
    203
    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
     
  12. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    Dude! You totally rule!

    I've seriously been trying to get that to work for like 2 weeks!

    Thanks!

    I owe you a pizza.

    :D :cool: :)
     

Share This Page

  • About ClutchFans

    Since 1996, ClutchFans has been loud and proud covering the Houston Rockets, helping set an industry standard for team fan sites. The forums have been a home for Houston sports fans as well as basketball fanatics around the globe.

  • Support ClutchFans!

    If you find that ClutchFans is a valuable resource for you, please consider becoming a Supporting Member. Supporting Members can upload photos and attachments directly to their posts, customize their user title and more. Gold Supporters see zero ads!


    Upgrade Now