onsitus
April 5th, 2005, 04:44 AM
Goodmorning.
Placed on the main stage I have a preloader_mc 'preloader' , an empty_mc 'container' and a radio_mc 'radio' (containing grafics and control buttons some loading tracks, other to control volume)
The 'preloader' is as followed.
Keyframe1 blank:
stop();
Keyframe2:
this.onEnterFrame=function(){
//trace the percentage of container loaded
percent=(_root.container.getBytesLoaded()/_root.container.getBytesTotal())*100;
if(!isNan(percent)){
//preloader's display
if (percent == 0) {
percent_display = "";
} else {
percent_display = Math.ceil(percent) + "% LOADED.";
}
// End of preloader's display
_root.container.stop();
}
if(percent == 100){
// this sends this preloader clip back to frame 1
// where it awaits the next call to it...
this.gotoAndStop(1);
// this deletes this onEnterFrame event...
// so that the movie clip stops looping...
delete this.onEnterFrame;
// preloader's display
percent_display = "";
// end of preloader's display
_root.container.play();
}
}
stop();
This preloader works fine with just the button in radio_mc to load music:
on (release) {
//check if data1 already loaded
if (_level0.radio.current_selection == "data1"){
stop();
} else {
//load data1
_level0.container.loadMovie("data1.swf");
//load preloader
_level0.preloader.gotoAndStop(2);
//set current_selection
_level0.radio.current_selection = "data1";
//set track title
var title = "Memory 1";
}
}
Now, I wanted to have some control over the volume of the music loaded into container and also a volume display. This was actualy working fine without the preloader. Put both together, and the loading button stops working.
In the radio_mc, I added to the first keyframe:
[AS]//create new sound
_root.container = new Sound();
var volPercent = 50;
//set volumeFill display
_root.radio.volumeFill._yscale = 50;
_root.container.setVolume(volPercent*2);
//set title track
var title = "Music Off";[/code]
And added a + and - buttons to control volume and volume display:
Minus button:
on (release){
if (volPercent != 0){
_root.radio.volumeFill._yscale -= 2;
volPercent -= 2;
_root.container.setVolume(volPercent * 2);
}
}
If I remove the _root.container = new Sound(); the music loads but then the volume controls are useless.
Could someone explain me what's going on in flashy's mind?
Well, that was a hard thread to write but I don't have the fla available at the moment.:P
Placed on the main stage I have a preloader_mc 'preloader' , an empty_mc 'container' and a radio_mc 'radio' (containing grafics and control buttons some loading tracks, other to control volume)
The 'preloader' is as followed.
Keyframe1 blank:
stop();
Keyframe2:
this.onEnterFrame=function(){
//trace the percentage of container loaded
percent=(_root.container.getBytesLoaded()/_root.container.getBytesTotal())*100;
if(!isNan(percent)){
//preloader's display
if (percent == 0) {
percent_display = "";
} else {
percent_display = Math.ceil(percent) + "% LOADED.";
}
// End of preloader's display
_root.container.stop();
}
if(percent == 100){
// this sends this preloader clip back to frame 1
// where it awaits the next call to it...
this.gotoAndStop(1);
// this deletes this onEnterFrame event...
// so that the movie clip stops looping...
delete this.onEnterFrame;
// preloader's display
percent_display = "";
// end of preloader's display
_root.container.play();
}
}
stop();
This preloader works fine with just the button in radio_mc to load music:
on (release) {
//check if data1 already loaded
if (_level0.radio.current_selection == "data1"){
stop();
} else {
//load data1
_level0.container.loadMovie("data1.swf");
//load preloader
_level0.preloader.gotoAndStop(2);
//set current_selection
_level0.radio.current_selection = "data1";
//set track title
var title = "Memory 1";
}
}
Now, I wanted to have some control over the volume of the music loaded into container and also a volume display. This was actualy working fine without the preloader. Put both together, and the loading button stops working.
In the radio_mc, I added to the first keyframe:
[AS]//create new sound
_root.container = new Sound();
var volPercent = 50;
//set volumeFill display
_root.radio.volumeFill._yscale = 50;
_root.container.setVolume(volPercent*2);
//set title track
var title = "Music Off";[/code]
And added a + and - buttons to control volume and volume display:
Minus button:
on (release){
if (volPercent != 0){
_root.radio.volumeFill._yscale -= 2;
volPercent -= 2;
_root.container.setVolume(volPercent * 2);
}
}
If I remove the _root.container = new Sound(); the music loads but then the volume controls are useless.
Could someone explain me what's going on in flashy's mind?
Well, that was a hard thread to write but I don't have the fla available at the moment.:P