A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: Variables in loading a music file

  1. #21
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    preferably yes
    show your php code

  2. #22
    Senior Member
    Join Date
    Sep 2004
    Posts
    113
    The fla is the one that I have attached and the contents of the php file is:

    PHP Code:
    <?php
    $id 
    $_GET['id'];
    if(isset(
    $id)){
            
    $db mysql_connect("localhost""root""");
            
    mysql_select_db("tracks4all",$db);
            
    $result mysql_query("SELECT * FROM tracks WHERE id = $id",$db);
            if (!
    $rec mysql_fetch_array($result)) {
                echo (
    "Sorry, no records found");
                }
            else {
                do {
                    
    $name $rec["file"];
                    
                    echo(
    "file=$name");
                }
                while (
    $rec mysql_fetch_array($result)); 
            }
    }
    ?>

  3. #23
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    echo("&file=".$name."&");

  4. #24
    Senior Member
    Join Date
    Sep 2004
    Posts
    113
    OK and Shall I keep the fla the same?

    because by just doing so it still doesn't work

  5. #25
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    RE : my post - 05-26-2007, 10:25 PM

    Flash receives - &file=song1.mp3&

    (Flash does not care how the variable is created, could be
    from text file, php file, asp file, xml file - it doesn't matter.
    what matters is the variable...it must be variable=value)

    the code in the above post works OK

    suggest you close your project.
    open a new file.
    test with the code i wrote above.
    when you have it working apply the logic to your project

  6. #26
    Senior Member
    Join Date
    Sep 2004
    Posts
    113
    I did what you said and I ended up with this.

    However it still doesn't play the file
    PHP Code:
    fileid _level0.id
    this.createEmptyMovieClip("myMusic",1000);
    myMusic = new Sound(myMusicMc);

    lv = new LoadVars();
    lv loadVariables("file.php?id="+fileid"_root");

    lv.onLoad = function(){ 
    myMusic.loadSound("../songuploads/"+lv.file); // defaults to event sound
    trace("Ready to play "+lv.file);
    }; 

  7. #27
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Code:
    fileid = _level0.id; 
    this.createEmptyMovieClip("myMusic",1000); 
    myMusic = new Sound(myMusicMc); 
    
    lv = new LoadVars(); 
    /// lv = loadVariables("file.php?id="+fileid, "_root");  // wtf is this??
    lv.id = fileid;
    
    lv.sendAndLoad("file.php", lv, "POST");
    
    lv.onLoad = function(){ 
    // myMusic.loadSound("../songuploads/"+lv.file);
    myMusic.loadSound("../songuploads/"+lv.file, true);
    // true  will stream the sound file
    // if false, or parameter omitted, will load but will not play
    trace("Ready to play "+lv.file); 
    };

  8. #28
    Senior Member
    Join Date
    Sep 2004
    Posts
    113
    Finally it works

    Thank you very much for all your help and support

    I have learnt a lot from this thread

    Thanks very much again

  9. #29
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    no problem
    glad to help you on your way
    good luck

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