Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Preloader For LoadSound() Object



Hey guys, I was just wondering if it's possible to create a working loadbar giving the status on a streaming mp3 file. All i want to do is, while the file is playing, for a little animation to show the percentage of the file that has actually been downloaded so far. F.Y.I. I checked out the code to Voets.' streaming xml player and that didn't help. Any ideas on how to get the percentage bar working?

For more information:

redload is a movie clip that should increase in width until reaching 100% (150 pixels wide), determined by bytes_loaded/bytes_total.

All music.php does is sends the full address of an mp3 file using the variable playsong.

Unfortunately, the percentageBar (loadbar) doesn't work and is commented out.

// CODE ---------------------------------------->

loadMySong = function () {
//this.mplayer.redload._width = 1.0;
htmlData = new LoadVars();
htmlData.load("music.php?dummy=" + Math.random());
htmlData.onLoad = function (true) {
if (true) {
playsong = this.play;
songname = this.name;
}
}
};

/*this.mplayer.percentageBar = function (true)
{
loaded = Math.round(theStream.getBytesLoaded());
total = Math.round(theStream.getBytesTotal());
getPercent = loaded/total;
this.mplayer.redload._width = getPercent * 150;
};*/

var theStream = new Sound();
mplayer.now_playing = "go ahead, make my day";
loadMySong();

mplayer.pause.onPress = function ()
{
theStream.stop();
mplayer.now_playing = "---";
};

mplayer.play.onPress = function ()
{
loadMySong();
theStream.stop();
mplayer.now_playing = songname;
theStream.loadSound("http://localhost:8000"+playsong, true);
//percentageBar();
};



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 06-07-2005, 05:53 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Sound Object & LoadSound();
Ok, so I have this problem: I have a music wav file on the net, lets say, myMusicURL. I have a one framed movie website and the code on its frame is this:
ActionScript Code:
music1 = new Sound();music1.loadSound("myMusicURL", false);optionstxt = "Downloading Music..."


optionstxt is a variable that a dynamic textbox on the scene uses. Then I have a mc w/ two keyframes and on its first frame I have:
ActionScript Code:
music2 = _root.music1;if(music2.getBytesLoaded() == music2.getBytesTotal()){    _root.optionstxt = "Playing..."    music2.start();    music2.setVolume(100);}


but, when test the movie, the textbox shows playing, because it thinks that the music object has loaded. well, it ain't

Help, anyone?

Sound Object & LoadSound();
Ok, so I have this problem: I have a music wav file on the net, lets say, myMusicURL. I have a one framed movie website and the code on its frame is this:
ActionScript Code:
music1 = new Sound();music1.loadSound("myMusicURL", false);optionstxt = "Downloading Music..."


optionstxt is a variable that a dynamic textbox on the scene uses. Then I have a mc w/ two keyframes and on its first frame I have:
ActionScript Code:
music2 = _root.music1;if(music2.getBytesLoaded() == music2.getBytesTotal()){    _root.optionstxt = "Playing..."    music2.start();    music2.setVolume(100);}


but, when test the movie, the textbox shows playing, because it thinks that the music object has loaded. well, it ain't

Help, anyone?

Sound Object Via LoadSound
Hi everybody, I searched on the forum to see if anybody has had the same problem I am having. And it seems that others have had similar bugs yet not similar solutions. I've tried everything I could think of.

I'm on the 40th frame, 25 fps. I'm using Flash MX.

at the first frame I have two buttons, you sets soundquality to true. true is high quality, and the other is for low quality which would be false. i've tried putting the s.onLoad in the onenterframe... that didnt work.

I also tried setting the isStreaming of the loadSound() to true.. and the sound started.. BUT i've never heard of this before, but the sound played at a high speed "alvin and the chipmunks" type speed!!! i know for a fact that my problem is not determining the soundquality boolean.

this code here does not work for me by the way, but i can not figure out why it wont


ActionScript Code:
s = new Sound();
s.setVolume(100);
if(songquality==true){
s.loadSound("bitterseed_hi.mp3",false);
s.onLoad = function() {
s.start(0,99);
}

Question On The Sound Object And LoadSound
i have a movieclip which after hitting the last frame does the following:


_root.ss = new Sound();
_root.ss.loadSound("track.mp3",false);


(makes a new sound object called 'ss' and gives it some sound.) this is all fine, now i have some sound but if i want to make a button called "change Track" that will change the '_root.ss'sound from 'track.mp3' to say 'track2.mp3' how can i do that?

i tried:

on(release){
_root.ss = new Sound();
_root.ss.loadSound("track2.mp3",false);
}

thinking that it would sort of overwrite it with this new track but it either just stops or or doesn't work at all.

Sound Object: LoadSound: Position
Hi there.

So I've just built a simple audio player in Flash MX for a project. I'm loading external MP3s with the loadSound() method of the Sound object.

Works fine.

I also have a progress bar that displays the percentage of the file that's been played. This works also, except...

...if I click to reload the sound while it is playing, even though it resets to the beginning of the sound, the script is still getting the position property as if the original sound had not been stopped.

Since there is no "unLoadSound()" function, I assumed that subsequent calls to loadSound() would result in the previous sounds getting destroyed.

Anyway, needless to say, this is frustrating me...how can I reset my visual progress bar so that it goes back to the beginning?

(I suppose I could create an entirely new Sound object on each click, but it seems like that would waste memory.)

LoadSound() And AttachSound() On Same Sound Object?
Is there a way to use attachSound() and loadSound() both on the same sound object? So far i can get both to work, but once loadSound() is called on the object, attachSound() no longer works.


ActionScript Code:
/*---- char voice behaviors ----*/
var char_sound:Sound = new Sound(charSound_mc);
// the library item that is called should be filename.mp3 in the identifier property, and exported for actionscript
// don't include ".mp3" in the function call.  example: say("filename");
say = function(id:String){
    char_sound.stop();
    char_sound.attachSound(id+".mp3");
    char_sound.start();
}
// the file that is called should be filename.mp3
// don't include ".mp3" in the function call.  example: say("filename");
sayExt = function(url:String){
    char_sound.stop();
    char_sound.loadSound(_global.path+url,true);
}
usage examples:

ActionScript Code:
say("intro");
sayExt("soundfile.mp3");

[MX] Sound Object Problem - LoadSound - I Cant Hear Anything
Hello,

I am loading a loop into my sound object. I have used getBytesLoaded and getTotalBytes to ensure that it is loaded but nothing seems to play. Here's the code anyway:


Code:
Function at the start of movie:

//loading the initial music
function musicLoopLoad(){
loopno = 1;

//the sound object
musicloop = new sound();
musicloop.loadSound("loop" + loopno + ".swf", true);
onEnterFrame = function(){
totalsound = _root.musicloop.getBytesTotal();
loadedsound = _root.musicloop.getBytesLoaded();
percent = (loadedsound/totalsound) * 100;

if(percent==100){
_root.musicloop.start();
onEnterFrame = null;
}
}
};

and then inside my main part of movie I have this:

//loading the initial loop
musicLoopLoad();


Any ideas?

Thanks for any help,

G

Preloader For Dynamic MP3 With LoadSound
I am using loadSound to load an external MP3 file. I was wondering if anyone knows a good tutorial on how to build a preloader for the MP3 or how to use the getBytesLoaded script with the sound variable. this is the basic idea or what im doing.

var music:Sound = new Sound();

music.loadSound("song1.mp3", true);


I want to make a preloader for this.

Thanks
chris

PS.. i know how to make a preloader for Movieclips so i get the concept just need to see a working code.

Preloader Not Working With LoadSound
Hi there,

Weird thing. I created a simple preloader and it works as it should- goes from one scene to the next. However when I put a sound in the second scene, via behaviour loudSound from library - it doesn't work.

the files (swfs and flas), are up on
www.strangeduck.com/clients/cg-261.sound.htm

I've included a sound only swf showing that the sound does actually play.


I'd appreciate any help on this matter.

Thnks,
Irene

Object Preloader
Does anyone in here know how to make a object preloader???
like an object that slowly fads or something instead of the percent preloaders??? plz help me out with this...

Preloader / Sound Object
I got some problems with my preloader:

I've insert a preloader-scene before my main scene. In this preloader-scene I have following code:

if (_framesloaded<_totalframes) {
gotoAndPlay(_currentframe-1);
}

now this worked perfectly until I stopped dragging soundfiles into frames but making sound objects instead:

frame1 of main scene:

loopSound = new Sound();
loopSound.attachSound("loopAcid");
loopSound.setVolume(70);
loopsound.start(0,999);

Since the code for the preloader isnt in frame 1, but the sound objects are loaded in frame 1 though, the preloader starts after all sound is loaded instead of before.

Can anyone tell me how I could make the soundobjects load after my preloader starts - on command ie?
(using Flash MX)

[FMX] MP3 Preloader And Sound Object
Hi all,

Houston? I have a problem... (no, really? hmmm... yes!)
Excuse my broken English (I will try to be clear).

I'm creating a MP3 jukebox for my website, a Movie Clip (MC) named "miniJuke". A function "preloadSound" is called, and should preload my sound object. But it doesn't work : I get a NaN until the movie is fully loaded and then I get 100.

Here is my code :



Quote:




// the sound preloader function, where "pieceOfCake"
// is the path to find my MP3

function preloadSound(pieceOfCake){
this.createEmptyMovieClip ("tempLoader",this);

tempLoader.onEnterFrame = function() {
var bl = mySound.getBytesLoaded();
var bt = mySound.getBytesTotal();
var p = isNaN(bt)?0 : Math.floor(bl*100/bt);

if (p < 100){
_root.miniJuke.percent.text = p;
trace ("that works ?");
}else{
mySound.start (0,99);
mySound.isPlaying = true;
tempLoader.removeMovieClip();
}
};
mySound.loadSound(pieceOfCake,false);
};







"percent" is a textfield, "mySound" is the sound object.
The "trace" instruction (that works?) is never displayed, so, i think than "p" is never lower than "100".

How to preload "mySound" correctly ?
I really need help.
Thx.

Sound Object And Preloader
How do you use the Sound Object without having to wait for the sound to load before the preloader of the movie is visible ?

Sound Object On Preloader
Hello all,

I have a sound object issue that has me stumped. I have a simple bar preloader that loads an flv. That works fine. I want to have a sound play while the flv preloads. So I used the Sound class. On the 1st frame I have

mySound = new Sound ();
mySound.attachSound ("bcl");
mySound.start (0, 1);

This works, the sound plays and everything, but it plays as long as the preloader is playing. I only want the sound to play once. I thought the 2nd argument for the start() method was a value to set how many times it plays.

I think it has something to do with my preloader code:

Frame 1:
var percent = (Math.floor (_root.getBytesLoaded() / _root.getBytesTotal() *100));

if(percent == 100){
gotoAndPlay(3);
}else{
gotoAndPlay(1);
}

Frame 2:
gotoAndPlay(1);

Since the preloader code is telling Flash to go back to frame one, which is where the Sound object code is, so it repeats until the movie is loaded. How do I get the sound to only play once while preloading?

What am I missing? Any help is greatly appreciated.

Greg

Null Object Using Preloader
I have a swf that is called preloader.swf..All it does is preload my main movie. The code for my preloader is:

PHP Code:




stage.scaleMode = StageScaleMode.NO_SCALE;stage.align = StageAlign.TOP_LEFT;var l:Loader = new Loader();l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);l.load(new URLRequest("content.swf"));function loop(e:ProgressEvent):void{    var perc:Number = e.bytesLoaded / e.bytesTotal;    preloader.txt.text = Math.ceil(perc*100).toString();}function done(e:Event):void{    removeChildAt(0);    preloader.txt = null;    addChild(l);}







and my content.swf contains:

PHP Code:




stage.scaleMode = StageScaleMode.NO_SCALE;stage.align = StageAlign.TOP_LEFT;stage.addEventListener(Event.RESIZE, resizeHandler);function resizeHandler(e:Event):void{    header.width = stage.stageWidth + 100;    bgClip.y = 0;    bgClip.x = 0;    bgClip.width = stage.stageWidth;    bgClip.height = stage.stageHeight;    bgClip.scaleX >  bgClip.scaleY ? bgClip.scaleY = bgClip.scaleX : bgClip.scaleX = bgClip.scaleY;}resizeHandler(null);







I am assuming the null reference is talking about the references to stage. I a mgetting this error:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at content_fla::MainTimeline/frame1()

What am I doing wrong here?

Preloader Not Working With CSS Object DIV
Preloader works perfect...until I remove the normal flash publish script - object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", and insert the CSS #DIV object {example;}

Here's my action script:

onClipEvent (load) {
totalBytes = _root.getBytesTotal();
}

onClipEvent (enterFrame) {
loadedBytes = _root.getBytesLoaded();
percentLoaded = Math.round(loadedBytes/totalBytes*100);
gotoAndStop(percentLoaded);
percentLoaded_txt.text = percentLoaded;
if (loadedBytes == totalBytes) {
_root.gotoAndStop("clouds");
}
}

Reason I want to do this is to get rid of the embed tag...

This CSS version works great with netscape & firefox, but on IE it doesn’t show the preloader counting to 100% (shows blank background color) and on IE 5.2 the swf doesn’t even load???

Anyone got this?
Thanks,
Boova

The html And CSS can be checked @
www.drjeff.godenny.com/index-test.htm

Null Object Using Preloader
I have a swf that is called preloader.swf..All it does is preload my main movie. The code for my preloader is:

ActionScript Code:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("content.swf"));

function loop(e:ProgressEvent):void
{
    var perc:Number = e.bytesLoaded / e.bytesTotal;
    preloader.txt.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
    removeChildAt(0);
    preloader.txt = null;
    addChild(l);
}
and my content.swf contains:

ActionScript Code:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

stage.addEventListener(Event.RESIZE, resizeHandler);
function resizeHandler(e:Event):void
{
    header.width = stage.stageWidth + 100;
    bgClip.y = 0;
    bgClip.x = 0;
    bgClip.width = stage.stageWidth;
    bgClip.height = stage.stageHeight;
    bgClip.scaleX >  bgClip.scaleY ? bgClip.scaleY = bgClip.scaleX : bgClip.scaleX = bgClip.scaleY;
}
resizeHandler(null);
I am assuming the null reference is talking about the references to stage. I am getting this error:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at content_fla::MainTimeline/frame1()
What am I doing wrong here?

Preloader And Sound Object
My Flash site has a media player which uses the attachSound method to play and skip through 3 mp3s. As a result the preloader shows up after the movie has loaded 60%. To rectify this, i changed the Publish Settings under the Flash Tab so that the classes for AS 2.0 load in the 2nd frame of the Preloader Scene(I have separated the preloader and the main movie to diffrerent scenes..)
I read it somewhere that to correct a similar problem with MCs, you need to place them somewhere in the timeline (say,Off Stage), But how can same be done for Sound Objects.???

[AS] MP3 Preloader And Sound Object
Hi all,
First time I post on this great website.

And... I have a problem... (no, really? hmmm... yes!)
Excuse my broken English (I will try to be clear).

I'm creating a MP3 jukebox for my website, a Movie Clip (MC) named "miniJuke". A function "preloadSound" is called, and should preload my sound object. But it doesn't work : I get a NaN until the movie is fully loaded and then I get 100.

Here is my code :


Quote:




// the sound preloader function, where "pieceOfCake"
// is the path to find my MP3

function preloadSound(pieceOfCake){
this.createEmptyMovieClip ("tempLoader",this);

tempLoader.onEnterFrame = function() {
var bl = mySound.getBytesLoaded();
var bt = mySound.getBytesTotal();
var p = isNaN(bt)?0 : Math.floor(bl*100/bt);

if (p < 100){
_root.miniJuke.percent.text = p;
trace ("that works ?");
}else{
mySound.start (0,99);
mySound.isPlaying = true;
tempLoader.removeMovieClip();
}
};
mySound.loadSound(pieceOfCake,false);
};





"percent" is a textfield, "mySound" is the sound object.
The "trace" instruction (that works?) is never displayed, so, i think than "p" is never lower than "100".

How to preload "mySound" correctly ?
I really need help.
Thx.

Rotating Object In Preloader?
Hey people,

I was surfing on the internet when I saw a site that has a pretty simple but cool preloader in it. The preloader comes from one of the flash movies on the site; http://www.weebls-stuff.com/toons/12/

As you can see the objects spins faster the further the loading process is. Can someone please explain to me how this is done, just the code, cuz I already know how to set up a preloader from the kirupa tutorial.

Preloader For Sound Object
I have a movie with three songs using the following code in frame 2:
Code:
song1 = new Sound();
song1.attachSound("song01", "song001", 1);
song2 = new Sound();
song2.attachSound("song02", "song002", 1);
song3 = new Sound();
song3.attachSound("song03", "song003", 1);
sound1_btn.onRelease = function() {
_root.mc_menu.soundRelease.gotoAndStop(2);
song1.start();
};
sound2_btn.onRelease = function() {
_root.mc_menu.soundRelease.gotoAndStop(3);
song2.start();
};
sound3_btn.onRelease = function() {
_root.mc_menu.soundRelease.gotoAndStop(4);
song3.start();
};
stop_btn.onRelease = function() {
_root.mc_menu.soundRelease.gotoAndStop(1);
stopAllSounds();
};
In frame 1 i have the following preloader script:
Code:
this.onEnterFrame = function(){
tb = this.getBytesTotal();
lb = this.getBytesLoaded();
if(lb >= tb){
delete this.onEnterFrame;
gotoAndStop(2);
}
}
and a text saying that the sound is loading. But when I play the movie i doesn't show the text. What am i doing wrong?

Null Object Using Preloader
I have a swf that is called preloader.swf..All it does is preload my main movie. The code for my preloader is:

ActionScript Code:
stage.scaleMode = StageScaleMode.NO_SCALE;stage.align = StageAlign.TOP_LEFT;var l:Loader = new Loader();l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);l.load(new URLRequest("content.swf"));function loop(e:ProgressEvent):void{    var perc:Number = e.bytesLoaded / e.bytesTotal;    preloader.txt.text = Math.ceil(perc*100).toString();}function done(e:Event):void{    removeChildAt(0);    preloader.txt = null;    addChild(l);}

and my content.swf contains:

ActionScript Code:
stage.scaleMode = StageScaleMode.NO_SCALE;stage.align = StageAlign.TOP_LEFT;stage.addEventListener(Event.RESIZE, resizeHandler);function resizeHandler(e:Event):void{    header.width = stage.stageWidth + 100;    bgClip.y = 0;    bgClip.x = 0;    bgClip.width = stage.stageWidth;    bgClip.height = stage.stageHeight;    bgClip.scaleX >  bgClip.scaleY ? bgClip.scaleY = bgClip.scaleX : bgClip.scaleX = bgClip.scaleY;}resizeHandler(null);

I am assuming the null reference is talking about the references to stage. I am getting this error:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at content_fla::MainTimeline/frame1()
What am I doing wrong here?

Rotating Object In Preloader?
Hey people,

I was surfing on the internet when I saw a site that has a pretty simple but cool preloader in it. The preloader comes from one of the flash movies on the site; http://www.weebls-stuff.com/toons/12/

As you can see the objects spins faster the further the loading process is. Can someone please explain to me how this is done, just the code, cuz I already know how to set up a preloader from the kirupa tutorial.

Sound Object On A Preloader
Hello all,

I have a sound object issue that has me stumped. I have a simple bar preloader that loads an flv. That works fine. I want to have a sound play while the flv preloads. So I used the Sound class. On the 1st frame I have

mySound = new Sound ();
mySound.attachSound ("bcl");
mySound.start (0, 1);

This works, the sound plays and everything, but it plays as long as the preloader is playing. I only want the sound to play once. I thought the 2nd argument for the start() method was a value to set how many times it plays.

I think it has something to do with my preloader code:

Frame 1:
var percent = (Math.floor (_root.getBytesLoaded() / _root.getBytesTotal() *100));

if(percent == 100){
gotoAndPlay(3);
}else{
gotoAndPlay(1);
}

Frame 2:
gotoAndPlay(1);

Since the preloader code is telling Flash to go back to frame one, which is where the Sound object code is, so it repeats until the movie is loaded. How do I get the sound to only play once while preloading?

What am I missing? Any help is greatly appreciated.

Greg

Flash Object And Preloader
Hey guys, I have a flash preloader and the swf object thingy where it checks to see if you have flash 8 and if you dont, it installs it. But for some reason, my preloader isnt working when i put that script in :(

Preloader That Moves Object Across Stage
I am making a sight for a mechanic and wanted to have a preloader that had a small image of a tow truck that moved from the left side(0%) of the stage to the right (100%), you get the idea. How do I get the percentage to move the clip across the stage?

this is my biggest genius attempt so far, but it does'nt work:

perc = Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100);
xperc = perc/780;
if (perc == 100) {
_root.gotoAndPlay(2);
} else {
nperc = perc;
tow._x =tow._x+= xperc;
nperc._x =tow._x;
}

any help would be much appreciated

Sound Object / Scene / Preloader Help
My knowledge of Flash MX is limited - especially ActionScript and I was trying to play around with sound objects because I can code but I seem to have a problem with launching them. My basic problem is this - I have 2 sound files that I want to put into a 'loader' the first one will play with the very start of the loader and set pictures to a set amount of time and then the second will loop continuously whilst 6 loading pages load.

So I thought put an Action Script command on my time line within my 'Loader Scene' to start the 2nd looping sound which I have definied at about frame 700 but for some reason the 2nd one doesn't play?!

My question is this - if you use the 'Linkage' method with sound objects what actually starts it off - because nothing happens - fair enough I understand exactly what 'Kenny SomethingOrOther' is saying on his tutorial but that's with buttons setting off the start and only works with an 'On ..' command because i get debug errors if i take it out. I just want to do it with Action Script related to a point in time within my 'Scene' and not user intervention ;

Do I need to put it in a 'Movie Clip' (I've tried that), do I need to put the sound somewhere special or is there a command i can put at the start of my scene which says start this loop at this frame?

Cheers in advance for any help - and if you live in East London I'll buy you a pint - because this is driving me nuts!


www.quitebad.com

Preloader Null Object Error
hi peeps
Debugging on AS3 gives me a headache, since I'm new in actionscripting.
i tried to debug my Preloader Class (AS3) problem without success:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Preloader$iinit()
at ufo_test_fla::MainTimeline/ufo_test_fla::frame1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Preloader/::onProgress()

Does somebody have an idea where the problem is?


ActionScript Code:
package {
   
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.text.TextField;
   
    public class Preloader extends Sprite{
       
        public var pl_mc:Preloader;
        public var loaded:Number;
        public var percent:Number;
        public var total:Number;
        public var pl_txt:TextField;
       
        public function Preloader()
        { //constructor

        this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
        }
                //Preloader
                function onProgress(e:ProgressEvent):void
                {
                    loaded = e.target.bytesLoaded;
                    total = e.target.bytesTotal;
                    percent = loaded/total;
                   
                    pl_mc.scaleX = percent;
                    pl_txt.text = "Loading... " + (Math.round(percent * 100)) + "%";
                    trace(percent);
                }
    }
   
}

I attached a Print Screen image.

Sound Object And Preloader Issue
Hi Folks!

Has anyone got an angle on the interference that linkage can create when the "export in first frame" option is ticked? I am using attachSound and the sound object to load an mp3 but it is wreaking havoc with the preloader.

If I uncheck the "export in first frame" box the sound does not seem to be instantiated. I believe that a way around this is to drag the sound onto the stage, but if you have 8 sounds for buttons for example, then you would have to create 8 sound layers - this seems a bit clunky to me!

My preloader code is:


Code:
stop();
_root.preloaderGraphics._visible = false;
this.onEnterFrame = function() {
if (this.getBytesLoaded()<this.getBytesTotal()) {
_root.preloaderGraphics._visible = true;
Total = this.getBytesTotal()/1000;
Received = this.getBytesLoaded()/1000;
Percentage = (Received/Total)*100;
_root.preloaderGraphics.percent = Math.round(Percentage)+"%";
_root.preloaderGraphics.progressBar._xscale = Percentage;
} else {
this.gotoAndPlay("intro");
this.onEnterFrame = null;
_root.preloaderGraphics._visible = false;
}
};
The preloaderMC also gets used by externalised swf files that are loaded into an empty MC with the instance name of "container".

I am loading the sound object like this:


Code:
var reviews:Sound = new Sound(this);
reviews.attachSound("kicksFM");
reviews.start();
As stated it makes the preloader initially display at 70% after an unacceptable lag!

Cheers

Andy

Preloader For Frames And Sound Object
I need to make a preloader to preload both all frames and a dinamically handled sound object.

right now the one I have works until I add the sound object dinamically.

[AS]Preloader + Buffering Ext. MP3 Sound Object
First of all, This forum has been a big help to me. Thanks for this great resource.

Anyways here is my question.

I have a preloader that preloads the intro to the site. Right now I have the mp3 embedded into the flashmove and it plays on the last frame in my intro. My problem is that makes the filesize of the SWF extremely huge. Here is what I want to do:

I created a new sound object, its source is going to be a external mp3 on the server, and i want it to "Stream". But I also need it to play right away when I call it. So can I pre-buffer it though the preloader with out the preloaded trying to load the whole mp3 in? Or buffer the mp3 while the intro is playing? My solution is to have optimal load time.

Here is my preloader code:


ActionScript Code:
// get size and calculate %
sofar = _root.getBytesLoaded();
total = _root.getBytesTotal();
percent = sofar/total;
percentnext = Math.round((sofar/total)*100);
percentdisplay = Math.floor(percent*100)+"%";
// when done preloading: start
if (percentnext == 100) {
    gotoAndPlay("start");
}


Here is my sound object code:

ActionScript Code:
soundtrack = new Sound(_root);
soundtrack.loadSound("soundtrack.mp3",true);


and I would call the soundobject to play on the frame using

ActionScript Code:
soundtrack.start(0,999);


SO is there away to buffer the audio while the into is running and then play it on the last frame.?

Thanks in Advanced.

Sound Object Stalling My Preloader...
The problem:
I load my audio first in the animation and then I start my byte counter (preloader)...but when I upload the flash file and view it in a browser I get nothing but a blank screen until the flash movie is 60% loaded.

Has anybody ever seen this and, if so, solved it??

what I want:
I need to use the Sound object to control my audio because I want to do a "fade out" when somebody moves to a different section of the animation.

here's how I set it up:
f1: I create a sound object and use my_mc.attachSound("ID name") to attach my audio from the library (setting a linkage name of course).

using attachSound directly effects the loading of my flash file. If I, for example, load another swf file with audio directly on the stage this doesn't happen.

f2-f4: I start all of the preloader loop so I can count down the bytes loaded, etc.

f5: movie starts...

Any ideas?

THANKS!
j.o.s.

Preloader For Movie With Linked Sound Object?
Hi,

I'm working on an audio player and am using the sound object linked from the library, rather than loaded externally. The MP3 is large (8MB), and plays fine (play, ff, rw, pause, stop) once loaded. The problem is that the entire .swf has to load before playing.

How (if I can) am I able to put a preloader in the first frame of the .swf? I've tried, but the preloader does not appear while the .swf is loading.

I'm new with Actionscript, so am not familiar with many audio techniques. I've searched the forums for an answer, but have found none.

Here is a link to the audio player...be warned - 8MB!

link to HTML page link to SWF file

thanks guys

Preloader Wont Work With My Sound Object.
Hello All.

I have a question about my preloader.

My sound object seems to be downloaded first rather than the preloader being displayed first.
I understand it probably has to do with the fact that I exported the soundobject in the first frame under linkage but I am not sure how to resolve my problem.
If I unclick the "Export into first Frame" option my sound doesn't seem to be playing.

I have used looping sounds in MCs and my preloader is working for those, but this time I want to use the sound object as shown below.

My current home page is http://www.fiskdesign.net

What I would like to do is to have my preloader display first and then the sound to start playing along with the animation.

(I attached below my AS I am currently using.)

I am greatful for any suggestions.

Henrik


// Pre Load Function
assessLoad = function (clip, endPreloadFunc) {
var kbLoaded = clip.getBytesLoaded()/1024;
var kbTotal = clip.getBytesTotal()/1024;
var percent = Math.floor(kbLoaded/kbTotal*100);
loaded.text = Math.floor(kbLoaded)+"Kb";
total.text = Math.floor(kbTotal)+"Kb";
bar._xscale = percent;
if ((kbLoaded/kbTotal == 1) && kbLoaded>1) {
endPreloadFunc();
}
};
endPreload = function () {
clearInterval(preload);
};
preload = setInterval(assessLoad, 100, this, endPreload);

// attach sound object
s1 = new Sound();
s1.attachSound("s1");
s1.start(0, 99999);
trace(s1.getVolume());
s1.setVolume(30);
play();

Sound Object / Scene / Preloader Help Needed
My knowledge of Flash MX is limited - especially ActionScript and I was trying to play around with sound objects because I can code but I seem to have a problem with launching them. My basic problem is this - I have 2 sound files that I want to put into a 'loader' the first one will play with the very start of the loader and set pictures to a set amount of time and then the second will loop continuously whilst 6 loading pages load.

So I thought put an Action Script command on my time line within my 'Loader Scene' to start the 2nd looping sound which I have definied at about frame 700 but for some reason the 2nd one doesn't play?!

My question is this - if you use the 'Linkage' method with sound objects what actually starts it off - because nothing happens - fair enough I understand exactly what 'Kenny SomethingOrOther' is saying on his tutorial but that's with buttons setting off the start and only works with an 'On ..' command because i get debug errors if i take it out. I just want to do it with Action Script related to a point in time within my 'Scene' and not user intervention ;

Do I need to put it in a 'Movie Clip' (I've tried that), do I need to put the sound somewhere special or is there a command i can put at the start of my scene which says start this loop at this frame?

Cheers in advance for any help - and if you live in East London I'll buy you a pint - because this is driving me nuts!


www.quitebad.com

Sound Object / Scene / Preloader Help Needed
My knowledge of Flash MX is limited - especially ActionScript and I was trying to play around with sound objects because I can code but I seem to have a problem with launching them. My basic problem is this - I have 2 sound files that I want to put into a 'loader' the first one will play with the very start of the loader and set pictures to a set amount of time and then the second will loop continuously whilst 6 loading pages load.

So I thought put an Action Script command on my time line within my 'Loader Scene' to start the 2nd looping sound which I have definied at about frame 700 but for some reason the 2nd one doesn't play?!

My question is this - if you use the 'Linkage' method with sound objects what actually starts it off - because nothing happens - fair enough I understand exactly what 'Kenny SomethingOrOther' is saying on his tutorial but that's with buttons setting off the start and only works with an 'On ..' command because i get debug errors if i take it out. I just want to do it with Action Script related to a point in time within my 'Scene' and not user intervention ;

Do I need to put it in a 'Movie Clip' (I've tried that), do I need to put the sound somewhere special or is there a command i can put at the start of my scene which says start this loop at this frame?

Cheers in advance for any help - and if you live in East London I'll buy you a pint - because this is driving me nuts!


www.quitebad.com

Object.watch() Or SetInterval, Whats Better? (4 Preloader)
Hi guys,

Just updating a few things on my preloader. At the momment it works off setInterval, but since I have been investigating and using Object.watch() is was wondering whether it would be "more effecient" to replace the setInterval methods with watch() callback functions.... I figure that way, instead of setInterval calling my "checkLoading" function every second, maybe I could use watch() to 'watch' the getBytesLoaded property of the thing im loading and call checkLoading function that way (to update progress bar).
HMmmmmmmm......
What do you think?

AS Moving Object Based On Preloader Percent
I am trying to move an object across the stage while my preloader is going. (i want two fists to meet when the preloader hits 100%). i am not very good with AS but i have tried things such as this.fist1_mc._x = percent + 100; but i am just taking shots in the dark at this point. i can post the file if need be.

conor

Preloader For Loader Object And Caching Questions
Guys.
I have a simple flash widget that i built that works like a small image gallery. It has a couple of tabs so that if you click on tab 1 you go to frame 1 and so on and so forth.

The tricky part is that I'm using a Loader to load the image for each frame.
Its very fast on my computer but when its hosted, I imagine there will be a delay as the image gets loaded. Because of that I want to add a simple preloader to the image (% loaded in top left corner).

I'm not sure how to go about this ...

I also wondered if I could get any technical link or insight into how flash caching works. I develop in PHP, .NET etc so don't be afraid to bust out the complicated version of things.

Thanks

Preloader Prototype Object...Works But Problems With TotalBytes
Hello, I have developed a preloader object that will load images off a server, and show the download stats. They only problem is, is that it is only showing the LoadedBytes figures and not the percentage or TotalBytes. I think this has something to do with the fact that the TotalBytes value is 0 or NaN thus the loadedBytes value can't be divided. So my question is, how do you get the TotalBytes value for a image coming into flash?
Is my flash movie running too fast do determine totalbyte size??

here is a link to a simple version of what I am trying to do. Please do take a look and you'll see what I am talking about.

I even tried putting the Image in an SWF but that doesn't work.

Preloader object

CODE
#initclip
function myPreloader(){
this.tempHolder = this._parent.createEmptyMovieClip("mainDisplay",10 )
this.bar._xscale = 0
this.txtPercent.text=""
this.txtbLoaded.text = ""
}

myPreloader.prototype = new MovieClip()

myPreloader.prototype.loadClip=function(file){
this.file = file
this.tempHolder.loadMovie(file)
this.txtbTotal.text = this.tempHolder.getBytesTotal()
this.bTotal = this.tempHolder.getBytesTotal()

myPreloader.prototype.onEnterFrame = function(){
this.bLoaded = this.tempHolder.getBytesLoaded()
//making bar size increase
this.bar._xscale = this.percent = Math.ceil(this.bLoaded / this.bTotal *100)

this.txtPercent.text=this.percent+"%"
this.txtbLoaded.text = Math.ceil(this.bLoaded / 1000) +"KB"
}
}
Object.registerClass("FPreloaderClass",myPreloader )
#endinitclip

Preloader Doesn't Work Properly With My Sound Object.
Hello All.

I have a question about my preloader.

My sound object seems to be downloaded first rather than the preloader being displayed first.
I understand it probably has to do with the fact that I exported the soundobject in the first frame under linkage but I am not sure how to resolve my problem.
If I unclick the "Export into first Frame" option my sound doesn't seem to be playing.

I have used looping sounds in MCs and my preloader is working for those, but this time I want to use the sound object as shown below.

My current home page is http://www.fiskdesign.net

What I would like to do is to have my preloader display first and then the sound to start playing along with the animation.

(I attached below my AS I am currently using.)

I am greatful for any suggestions.

Henrik


// attach sound object
s1 = new Sound();
s1.attachSound("s1");

// Pre Load Function
assessLoad = function (clip, endPreloadFunc) {
var kbLoaded = clip.getBytesLoaded()/1024;
var kbTotal = clip.getBytesTotal()/1024;
var percent = Math.floor(kbLoaded/kbTotal*100);
loaded.text = Math.floor(kbLoaded)+"Kb";
total.text = Math.floor(kbTotal)+"Kb";
bar._xscale = percent;
if ((kbLoaded/kbTotal == 1) && kbLoaded>1) {
endPreloadFunc();
}
};
endPreload = function () {
clearInterval(preload);
};
preload = setInterval(assessLoad, 100, this, endPreload);

http://www.flashkit.com/board/newthread.php#

[F8] How To Make Preloader And Sound Object Play Nice?
'm building this file, and it's not an unusual, or even very challenging file. It's a long keyframe timeline animation, with a mute on/off button for the one sound object, and a pause/start button to control the whole movie.

Everything works, until I try to introduce a preloader.

Seems like preloaders and soundobjects don't like each other.

I've tried:

- preloader in main file: won't display the preload animation, whether or not the soundobject is exported to first frame (from linkages menu).

- external preLoader swf, with loadClip. This works, EXCEPT that the sound will only play if it's in the timeline. If I introduce the sound in the main movie as a soundobject, it plays in the main movie, but not when it's preloaded through an external preloader swf.

Now, I can think of a few things, but I'm a little daunted by the prospects.

1) Is there a way to control sound volume (only one sound file in entire file), without introducing the mp3 in a sound object? If yes, what/where?

2) I can use Ken Bellow's tutorial code
( http://www.kennybellew.com/tutorial/...ttachsound.htm )
to create an external swf containing only the audio file, and then use loadSound in the main movie to create a preloader for the sound only, but i still have another 800k or so in the main movie that I need to preload, so I need to preload BOTH the audio and the main file, and I don't know how to create a VAR that adds both of those, and base the percentloaded on that.

Any advice/guidance greatly appreciated. There are so many flash files with audio and UI, this must be a problem people deal with all the time....

Thanks!

How To Make Preloader & Sound Object Play Nice?
I'm building this file, and it's not an unusual, or even very challenging file. It's a long keyframe timeline animation, with a mute on/off button for the one sound object, and a pause/start button to control the whole movie.

Everything works, until I try to introduce a preloader.

Seems like preloaders and soundobjects don't like each other.

I've tried:

- preloader in main file: won't display the preload animation, whether or not the soundobject is exported to first frame (from linkages menu).

- external preLoader swf, with loadClip. This works, EXCEPT that the sound will only play if it's in the timeline. If I introduce the sound in the main movie as a soundobject, it plays in the main movie, but not when it's preloaded through an external preloader swf.

Now, I can think of a few things, but I'm a little daunted by the prospects.

1) Is there a way to control sound volume (only one sound file in entire file), without introducing the mp3 in a sound object? If yes, what/where?

2) I can use Ken Bellow's tutorial code
( http://www.kennybellew.com/tutorial/...ttachsound.htm )
to create an external swf containing only the audio file, and then use loadSound in the main movie to create a preloader for the sound only, but i still have another 800k or so in the main movie that I need to preload, so I need to preload BOTH the audio and the main file, and I don't know how to create a VAR that adds both of those, and base the percentloaded on that.

Any advice/guidance greatly appreciated. There are so many flash files with audio and UI, this must be a problem people deal with all the time....

Thanks.

Sound Object Making Preloader Scence Stuck So Long
Hello, :)

I need some help from somebody that can give the advice about sound object. The sound object that export for actionscript at the first frame make my preloader stuck from loading sound about 500 KB before preloader bar appear. Viewer can't wait for nothing telling them what will happen while my movie try to load these sound for 500 KB without showing my loader bar & percentage loading. How will I do?

Thank you,
Kathryn


Preloader Problem - _root.getBytesLoaded() Doesnt Include Sound Object?
I am using a function based on _root.getBytesLoaded() in a preloader progress bar, which I always use and works fine

I am working on a particular project that has quite a large sound track file, and since adding this, the preloader doesnt work right, the screen is blank for about 8 seconds before the preloader appears, and even then the progress bar is about 90% complete when it DOES appear.

Am I right in thinking that the large sound file is being ignored (removing it cures the delay)

FYI, the movie is 2 scenes, first is the preloader. The sound object for the big file is declared at the start of scene 2

Thanks!

Loadsound?
Hi....how does the loadsound action work? I wanna make some mp3's streamable. I tried to type in a path for an mp3 file located on my server but nothing happens? I wanna have a bunch of mp3's accessable to the public. I know how to use the get Url actions but that downloads the whole song before starting to play! The loadsound is what i think i should use right? I know that its posible to load a new sound into a soundobject somehow? Someone suggested to do a loadmovie (swf) and have each mp3 embedded in it's own (swf)? but I really wanna use the loadsound since thats what it's there fore I think? Any help is highly appreciated!

LoadSound Bug
When using a streaming loaded sound with Flash my computer only plays it when I test publish the flash file and not on the internet... I have also tried listening to other site's streaming music and get nothing?

I have the latest version of the Flash Player (6 r65) and the MP3's are cahced on my machine... they just won't play?

Anyone had this problem?

Loadsound()
Frame 1:

mysound = new sound();
mysound.loadSound("World_Tr-Q-Music-7715_hifi.mp3",false);
if(mysound.getBytesLoaded() == mysound.getBytesTotal()) {
mysound.start(0,1000);
gotoAndPlay("Scene 2",1);
}
else {
gotoAndPlay(2);
}


Frame 2:

gotoAndPlay(1);

this is all in scene 1, scene 2 is the main movie...

every time i play that the movie stops responding... can anyone help?

example... http://systemor1.hopto.org/main.html

Loadsound
My goal was to make a flash version of winamp which would load a selected song from my webspace and play it with all the normal controls. now it works PERFECTLY when the songs and the swf are on my hard drive, yet the instant i upload them, it wont load the songs!

on (press) {
_root.music = new Sound();
location = "/music/" add _root.names[_root.i] add ".mp3";
_root.music.loadSound(location, false);

if (Number(_root.bufferd)>10) {
_root.music.start();
}
}

is the code i use to load the sounds. _root.names is an array of song names. this loads them from the /music/ folder on my hard drive but it wont work of the net :/

has anybody come accross this before? is there something im doing wrong?

Any help apreciated!

Copyright © 2005-08 www.BigResource.com, All rights reserved