A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Passing data to php

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    26

    Passing data to php

    I am working on an educational website. My Flash movie with end with a score I need to send back to the site to store in a database. I am some what new to flash, and have looked for the method on how the get data back to the site, and have not had much luck. My website uses PHP, and in written useing the CakePHP framework. I have created a test page on the site, and it shows what was submitted. All I need to do know is get the submission from flash to php.

    I have to following code attach to some text I converted to a button:
    on (release) {
    var scoredata:LoadVars = new LoadVars();
    scoredata.activitie = "001";
    scoredata.score = Score;
    scoredata.send('http://localhost/flash/submit/001/' + Score,"_self","POST");
    }
    and nothing seem to work. Like I said I am new to flash, and do not have a clue if this is correct or not. If someone could take a look and tell what coul be wrong, I would appreciate it. Thanks, Troy.

  2. #2
    Member
    Join Date
    Aug 2012
    Posts
    55
    use sendAndLoad method, see this link for an example http://www.actionscript.org/forums/s....php3?p=658460

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    26

    Question

    I was using send because once the webpage get the data, it will save it to a database and got to another page. I have discover that I need to test this out of IDE to make it work. Only question I have at the moment is cand I use a url similsy to the one in my original post? I am creating this site using a PHP Framework (CakePHP) that uses "pritty" URL. So I can create the url and, if possible, pass the data in the url. For example, the url /flash/submit/001/100 the flash and submit determine the page to call and the 001 and 100 is the data being sent. Creating the url is not an issue, I need to make sure it gets to my website. Thanks, Troy.

  4. #4
    Member
    Join Date
    Aug 2012
    Posts
    55
    don't know anything about Cake.. sorry. can't help you there. try googling.

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    26
    Another thing just occured to me. How about calling a website from Flash? That may do what I want it to.

  6. #6
    Junior Member
    Join Date
    Sep 2012
    Posts
    26
    Okay, I have the text "Submit Score" on my final frame. I made this text a button by pressing F8 and adjusting the setting in the dialog. I then added the code:

    on (release) {
    getURL('http://localhost/flash/submit/001/' + Score);
    }

    attached to the button. When I get to the final frame and click on submit score, nothing happens. What am I doing wrong? Thanks Troy

  7. #7
    Member
    Join Date
    Aug 2012
    Posts
    55
    on(release){
    getUrl(”http://yourwebsite.com”)
    }

    just put this in a button

    you might have to add a + ' after Score
    Last edited by rachelg; 09-13-2012 at 03:19 PM.

  8. #8
    Member
    Join Date
    Aug 2012
    Posts
    55
    try this

    toUrl = "http://localhost/flash/submit/001/" + Score +".html";
    getURL(toUrl);
    Last edited by rachelg; 09-13-2012 at 03:30 PM.

  9. #9
    Junior Member
    Join Date
    Sep 2012
    Posts
    26
    Thanks for the help. I got it working. Your suggestion worked well, the one ar 2:15, not the last one. The code that worked is:
    on(release){
    getUrl("http://chirasedsite.local/flash/submit/001/" + Score);
    }
    There is not need for the ".html", but that is part of theweb framework I am using, nothing related to Flash. Thanks again for the help, I am greatfull.

Tags for this Thread

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center