Variables in loading a music file
I am trying to load a file which i assined using a variable
here is my AS:
PHP Code:
file = _level0 . id ;
loadVariables ( "file.php?id=" + file , "_root" );
myMusic = new Sound ( myMusicMc );
myMusic . loadSound ( "../songuploads/song1.mp3" );
//myMusic.loadSound("../root/soundfiles/"+file);
But it only loads when i explicity say the location
What shall I do?
5+5=55
Try tracing _level0.id to see what you get.
i get the name of the file that should be played
i know the variable works fine becuase i have it displayed in a textbox
try defining file = _root.id on a frame before you make the loadVariables call...
this could be an issue of id being undefined when loadVariables gets called.
The variable is being defined and retreived properly.
What I am having trouble with is getting it to load:
myMusic.loadSound("../soundfiles/"+file);
did you try something like:
myMusic.loadSound("../soundfiles/song"+file+".mp3");
the varaible file contains "song1.mp3" so I don't need to do so.
is there a way I can debug it and see the variables in real-time in the browser?
FK'n_dog
the issue is timing
you load via loadVariables and a nano-second later you try to use the variable
it will always fail (even though you can see the variable in a textfield)
use a loadvars object, it has an onLoad function that runs when all
data has completed loading
what do you mean by:
use a loadvars object, it has an onLoad function that runs when all
data has completed loading
Would putting it on a diffrent frame work?
FK'n_dog
FK'n_dog
Code:
file = _level0.id;
myMusic = new Sound(myMusicMc);
sv = new LoadVars(); // send object
sv.id = file;
lv = new LoadVars(); // load object
sv.sendAndLoad("file.php", lv, "POST");
lv.onLoad = function(){
trace(lv.file); // php should return - file=song1.mp3
myMusic.loadSound("../root/soundfiles/"+lv.file);
};
this might work
thank you very much for that.
I have one more question.
How do I stop it after 15 seconds of playing?
FK'n_dog
use setInterval to check the sound.position property -
Code:
function checker(){
trace(myMusic.position);
if(myMusic.position > 15000){
myMusic.stop();
clearInterval(posINT);
}
};
lv.onLoad = function(){
myMusic.loadSound("../root/soundfiles/"+lv.file, true);
posINT = setInterval(checker,500);
};
Sorry for the late reply but I have only managed to try and put it all together and it doesn't seem to work.
This is what I have at the moment:
Code:
file = _level0.id;
myMusic = new Sound(myMusicMc);
sv = new LoadVars(); // send object
sv.id = file;
lv = new LoadVars(); // load object
sv.sendAndLoad("file.php", lv, "GET");
lv.onLoad = function(){
trace(lv.file); // php should return - file=song1.mp3
myMusic.loadSound("../soundfiles/"+lv.file);
songstat = "Ready to play "+lv.file;
};
The reason I am using get is becuase the URL for getting the file name is file.php?id=1
and the output is Where Am I going wrong? I went through it over 5 times and I still can't see.
Thanks and sorry again for bumping the thread up
FK'n_dog
loadSound accepts 2 parameters -
url of sound file
boolean true/false -- true is streaming, false is event
Streaming sounds play while they are downloading
Event sounds are completely loaded before they can be played
If the second parameter is omitted, it defaults to false .
I ran a simple test with a text file and a button to start the sound -
Code:
this.createEmptyMovieClip("myMusic",1000);
myMusic = new Sound(myMusicMc);
lv = new LoadVars();
lv.load("song.txt");
lv.onLoad = function(){
myMusic.loadSound(lv.file); // defaults to event sound
trace("Ready to play "+lv.file);
};
/*--song.txt--
&file=song1.mp3&
*/
btn.onRelease = function(){
myMusic.start();
};
OK I see
but how can i integrate this with PHP?
Please have a look at the fla and see where i am going wrong.
Attached Files
Last edited by abdulgomaa; 05-27-2007 at 05:29 AM .
can anyone have a look at the file and tell me where I am going wrong?
FK'n_dog
but how can i integrate this with PHP?
i used a variable from a text file to test
you must get your php to return the variable -
&file=song1.mp3&
does it have to have & at the front and end?
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width