A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: loader never completes PHP page call? (only a problem on server - works fine locally)

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    6

    loader never completes PHP page call? (only a problem on server - works fine locally)

    (I've boiled my problem down to a simple example):
    with AS3, I try to load a PHP file which is stored on my server (code below).
    This PHP file only does one thing: echo a string.

    When I compile my flash file: the loader finishes, and I see the echoed string.
    But, when I copy this exact flash file to my server: the loader never seems to finish. I never see the echoed string.

    (+ I'm appending strings to a dynamic textBox on the stage. Sort of like tracing every step of my progress. No further strings appear after I load, so I assume this where it is dying.)

    MY GUESS: this must be some sort of permissions problem. Like maybe the server won't let some (flash) files call other (php) files? (permissions are rw-rw---- ... but temporarily changing to rwxrwxrwx didn't seem to help). Snarky tech friends assure me the problem must be in my code.
    (I'm definitely out of my depth).

    help?

    ----------------PHP FILE CODE:
    <?php
    header('Content-Type: text/html; charset=utf-8');
    echo("youAccessedME...");
    ?>


    ----------------PHP FILE CODE:
    package {
    import fl.controls.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.net.*;

    public class testingPHP extends MovieClip{
    public function testingPHP() {
    st_SaveData.addEventListener(MouseEvent.CLICK, saveGame); //when button clicked...
    var tf_StatsPop:TextFormat = new TextFormat();
    tf_StatsPop.font = "Arial";
    stDBecho.defaultTextFormat = tf_StatsPop;
    stDBecho.text = "welcome. ";
    }
    public function saveGame(evt:Event):void{ //submit button has been clicked.
    stDBecho.text = "saving: ";
    var myPrequest:URLRequest = new URLRequest();
    myPrequest.url = "http://www.oregonstate.edu/instruct/dce/css440/MemoryTool/test.php";
    var loader:URLLoader = new URLLoader();
    loader.load(myPrequest); //sends the request
    loader.addEventListener(Event.COMPLETE, storeToServerLAST);
    }
    public function storeToServerLAST(evt:Event):void{
    stDBecho.appendText(". entered final stage. ");
    stDBecho.appendText(". End result:" + evt.target.data);
    }
    }
    }

  2. #2
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Is the swf and php file on the same server in the same folder?
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    6
    They are, Paul.

    On a whim, I just went in and shortened the myPrequest.url string to be just "test.php" and: it totally works now!

    (thanks!)

    Still curious what the official description of this problem would be, if anyone knows. ("my server doesn't allow full URL requests"? some sort of security thing?). I'd like to go back to my tech friends and say "oh, the problem was {this}"

  4. #4
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Sometimes when using absolute urls this can cause it to break]
    For example pathString = "http://www.somedomain.com/somescript.php"
    this will work if you are accessing the site via http://www.somedomain.com/
    But if you access the site via http://somedomain.com/ it wont work.
    This is why it is best to use relative paths. Example: pathString="someScript.php"

    You can find out more about "absolute" and "relative" here.

    Hope it helps
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

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