dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: help with PHP and AC2

  1. #1
    Junior Member
    Join Date
    Jan 2016
    Posts
    4

    help with PHP and AC2

    So I want to write to a text file using php by calling in AC2. I keep trying to google answers and trying solutions but none are working. Maybe someone here could help?

    PHP
    PHP Code:
    <?php
    $fscrn 
    $_POST['fscrn']
    $saveTO "full=".$fscrn."&"

    $openTO fopen ("video.txt""a");
    fwrite($openTO$saveTO);
    fclose($openTO);
    ?>

    Code:
    function sendConfigVideo(setting)
    {
    	var videoVar = new LoadVars();
    	videoVar.fscrn = "true";
    	videoVar.sendAndLoad("config/video.php",videoVar,"POST");
    }
    I set permissions and everything, but it still doesn't work.

    location of txt and php are relative to the swf.

  2. #2
    Senior Member
    Join Date
    Aug 2012
    Posts
    124
    yes,

    you code work ok except for ; missing in two place
    PHP Code:
    <?php

        $fscrn 
    $_POST['fscrn'];
        
    $saveTO "full=".$fscrn."&";
        
        
    $openTO fopen ("video.txt""w");
        
    fwrite($openTO$saveTO);
        
    fclose($openTO);

    ?>
    you might want "w" instead of "a" too as append text, not write each time.

    if you want append text then you need to do a little tweaking with if not empty file etc ect

  3. #3
    Junior Member
    Join Date
    Jan 2016
    Posts
    4
    Still doesn't work. NOTE: It is not on a server, it is in a file on my computer. Could that be the problem?
    PICTURES:
    https://gyazo.com/918b0d9bcdb51996089b5d45846d1fd2
    https://gyazo.com/e758818fe895183b003e5b0fa5741abf

  4. #4
    Senior Member
    Join Date
    Aug 2012
    Posts
    124
    hell, you need to set up a server if you do not already have one http://www.wampserver.com/en/

    or you can use shared object with as2 without text file, plenty of information on this everware

    or you could use AS3 which can do it directly using FileReference(), no need for server or php

  5. #5
    Junior Member
    Join Date
    Jan 2016
    Posts
    4
    Quote Originally Posted by Terrencing View Post
    hell, you need to set up a server if you do not already have one http://www.wampserver.com/en/

    or you could use AS3 which can do it directly using FileReference(), no need for server or php
    Is a server necessary? I just want it to be in my file system. Is there any other way?

  6. #6
    Senior Member
    Join Date
    Aug 2012
    Posts
    124
    i edit last answer, read over.

    you can use shared object with AS2, but no can save to text file without server side file if use AS2.

    you can manually use and edit the text file too.

  7. #7
    Junior Member
    Join Date
    Jan 2016
    Posts
    4
    Quote Originally Posted by Terrencing View Post
    i edit last answer, read over.

    you can use shared object with AS2, but no can save to text file without server side file if use AS2.

    you can manually use and edit the text file too.
    The thing is, I can pass variables through the php file, and it will echo in flash. I think the problem is with the code, not with php being local

  8. #8
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,025
    the script works fine, with the syntax fix that terrence mentioned so you just need:
    PHP Code:
    <?php

        $fscrn 
    $_POST['fscrn'];
        
    $saveTO "full=".$fscrn."&";
        
        
    $openTO fopen ("video.txt""w");
        
    fwrite($openTO$saveTO);
        
    fclose($openTO);

    ?>
    and your swf:
    PHP Code:
    function sendConfigVideo(setting){
        var 
    videoVar = new LoadVars();
        
    videoVar.fscrn "true";
        
    videoVar.sendAndLoad("video.php",videoVar,"POST");
    }
    _root.sendConfigVideo(); 
    maybe it doesnt work for you because you don't call the function

  9. #9
    Senior Member
    Join Date
    Aug 2012
    Posts
    124
    if you still have the problems, zip up all you files and attach them here.
    you will get it to echo in flash, flash kind of have own server ish built in.
    you will not get it to work without server on own computer in broswer.

    use shared object in AS2 if not use server, use AS3 to do without shared object or server, straight forward, can use AS3 with shared object also.

    or maybe if you go back to flash 5 you can do it without server.

    no need always call things with _root at front part

    it would be more like "sendConfigVideo(someVar or String);" even though you not use setting in you code.

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