SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)

    A sucker going in head first

    I've decided, even though I have no flash experience and very little graphical experience, that I am going to try to create a flash "program" (I hope that is the right word). This program will be very similar (actually, I am going to try to mimic it) to something found at espn.com. They have a poll that will allow you to vote and then display the results in a rather cool way.

    So, after you all have your fun telling me I'm an idiot, how should I approach this? I do know JavaScript and it seems that ActionScript is very similiar (yes, I know that it is still its own language with its own twists) so I'm not too worried about writing the necessary code for it. But, obviously, there are some thiings that would be done better if I had experience. But since I don't, I'd like to tap into all of yours.

    Any advice would be great. Don't baby talk me! But seriously offer me direction. Some step-by-step directions would be cool but I would also appreciate you pointing me to the right tools to use.

    And if I crash and burn I'll sing songs of praise to those who helped before I fade away....

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Here's where I stand: I've made the basic form that my poll will use. I can submit the form to a php script which processes the information and then returns whatever it expected.

    Here's where I am stuck: I do not get any errors while testing but I do not get what I expect. The form is supposed to submit the form values to the PHP script which then just returns it. The actionscript should then display the results in a text box. I cannot get it to print the results. However it does print the default text (Your vote has been counted...)

    Here's the code. If you need to see the .fla file, I can upload it for review.

    Action Script
    Code:
     
    function onSubmit() {
     // Initialize form variables:
     formData = new LoadVars();	
     formData.rating = "";
     
     // Get radio button selection:
     formData.rating = radioGroup.getValue();
      
     // Create LoadVars instance to receive server variables:
     replyData = new LoadVars();
     
     // And define a callback handler for that instance:
     replyData.onLoad = handleReply;
     
     // Initialize replyData variables:
     replyData.reply_rating = "";
     
     // Submit the data and tell the user.
     // Change the URL to point to the PHP file on your web server.
     formData.sendAndLoad("http://www.johnnysjokes.com/test/flash/survey.php", replyData, "post");
    }
    function handleReply(success) {
     if(success == true) {
      message_txt.text = "Your vote has been counted:" + newline;
      message_txt.text += "You rated this site a "+ replyData.reply_rating + newline;
     } else {
      message_txt.text += "There was a problem submitting your vote.";
     }
    }
    PHP
    Code:
     
    <?
     $reply_rating = $rating;
     echo "reply_rating=" . urlencode($reply_rating);
    ?>
    If anyone has encountered something like this before, I would appreciate feedback. It seems like I am overlooking something small but I cannot seem to find it.

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A couple of things. You don't really need the extra object to handle the return data unless you really want to use it. You could just use.
    Code:
     
    function onSubmit() {
    formData = new LoadVars(); 
    formData.rating = radioGroup.getValue();
    formData.onLoad = handleReply;
     
    formData.sendAndLoad("http://www.johnnysjokes.com/test/flash/survey.php", this, "post" );
    }
    function handleReply(success) {
    if(success == true) {
    message_txt.text = "Your vote has been counted:" + newline;
    message_txt.text += "You rated this site a "+ this.reply_rating + newline;
    } 
    else {
    message_txt.text += "There was a problem submitting your vote.";
    }
    }

    So would work just fine. Also are you sure PHP script isn't causing the problem. Try using
    Code:
    formData.send("http://www.johnnysjokes.com/test/flash/survey.php", "_blank", "POST" );
    It should send the vars and open a new window and you should see the proper output from the PHP script.

  4. #4
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by freddydoesphp
    A couple of things. You don't really need the extra object to handle the return data unless you really want to use it. You could just use.
    Code:
     
    function onSubmit() {
    formData = new LoadVars(); 
    formData.rating = radioGroup.getValue();
    formData.onLoad = handleReply;
     
    formData.sendAndLoad("http://www.johnnysjokes.com/test/flash/survey.php", this, "post" );
    }
    function handleReply(success) {
    if(success == true) {
    message_txt.text = "Your vote has been counted:" + newline;
    message_txt.text += "You rated this site a "+ this.reply_rating + newline;
    } 
    else {
    message_txt.text += "There was a problem submitting your vote.";
    }
    }
    So would work just fine.
    This wouldn't work for and I am not sure why.



    Quote Originally Posted by freddydoesphp
    Also are you sure PHP script isn't causing the problem. Try using
    Code:
    formData.send("http://www.johnnysjokes.com/test/flash/survey.php", "_blank", "POST" );
    It should send the vars and open a new window and you should see the proper output from the PHP script.
    The PHP page was the cause of the error. Some misplaced comment tags were the root of the problem. Once they were fixed, all worked well.

    Now on to phase two which happens to be the real bread and butter of what I am trying to do. I know want to display the results in a bar graph. Actually, I want the bar graph to display the results in an animation (see espn.com once again for the example I am basing this on). I know I will need to have the PHP page return the results of the survey to the flash file. That part I can handle. What I need to know then is where to begin! I am sure this will involve multiple frames and some actionscript to do the calculations. I'm just not sure how to basically start. My guess is I will need to use ActionScript to retrieve the results, calculate them, and then start to create the animation. Im going to review the functions available in actionscript to see if I can find any functions that will seem to suit my needs. If anyone can point me in the right direction, or correct what I believe to be the course of action, I will certainly appreciate the guidance.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •