1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Rep Power

    [MX] LoadVars - Php

    I am trying to get a movie to load a sound file (mp3) from a variable I set in a Php script. Everything works fine when I loadSound from a static link, but I can't find a good example of using a variable as an argument.

    // Here's the action script: ////////////////////////////

    getSound = new loadVars();
    varPlay = getSound.trans;

    translate = new Sound();

    _root.playButton.onRelease = function() {
    translate.loadSound(varPlay, true);
    //translate.loadSound("http://localhost/calpass/assets/sounds/intro.mp3", true);
    _root.stopButton.onRelease = function() {

    // Here is the Php file: (simple for testing) ////

    $outSound = "trans=http://localhost/calpass/assets/sounds/intro.mp3";
    echo $outSound ;

    // Here's the error I get when I testMovie in flash MX //////

    Error opening URL "file:///G|/CAL%5FHS/www/assets/flash/"

    When I put the swf file into a web page within a live site nothing happens.

    I sure could use some help. I'm new at action script and I'm having a hard time finding a good reference for this.


  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Rep Power
    I'm not sure if this is your problem but it is something that you should look into. When you are loading variables with flash, the script won't wait for the variables to be loaded if you are loading them form an external source. So when you are trying to use the variable that you loaded from the php script, its not seeing a value becuase it isn't loaded yet. The only solution i found is this. The variable string that you are sending back, add a value at the end of it like "isLoaded=1", so your php file will be something like this:
    PHP Code:
    echo "sound=http//yoursound.mp3&isLoaded=1" 
    Then in your flash movie, on the first frame call your load function, then on the second frame do a check for isLoaded == 1. If it is jump to something like frame five, and there is where you can put the rest of the code. Otherwise, make sure that frame four jumps back to frame 2 to check if isLoaded == 1. In effect you'll be looping between frame 2 and four until your variables are loaded. then you will jump to frame five, and all your variables are loaded. I hope i made some sense.

IMN logo majestic logo threadwatch logo seochat tools logo