Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Now...sound issue...won't play first time...

Status
Not open for further replies.

fedtrain

Instructor
Jun 23, 2004
142
US
I am attempting to build a file that has some draggable clips that when a hit test is positive a sound is loaded and played.

The problem is that it won't play on the first drag...it plays on second one though...this is getting really frustrating.

Code:
function whatHit(a, startPosx, startPosy){
   var whatDragged = a;
    if (this[whatDragged].hitTest(mcTarget)){
       this[whatDragged]._x = startPosx;
       this[whatDragged]._y = startPosy;
       sound.loadSound ("/audio/" + whatDragged + ".mp3",false)		
       sound.onLoad= function(success:Boolean) {
           trace (success);
           if (success) {
             sound.start(0,3);
           }
      }
  }
     else {
        this[whatDragged]._x = startPosx;
        this[whatDragged]._y = startPosy;
     }
 }

When I am testing...ctl+enter...I get times when it won't load...then times when it works fine. (On the same machine.) But when I open the .swf...it never works on first try...but will play on second.

What is wrong? What am I missing?

Dave

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Ok, I saw something to that effect, but no real answer on how to do that.

Also, these clips are tiny, comparatively...120k to 200k.

Lastly, I thought that was what I was doing with the if success statement.

And....now here is the part that doesn't make sense to me. I have three sounds on one page. Drag any one of them...and the sound won't play. Drag any one of them again...and the sound plays. This happens even if you drag a different sound the second time.

So that to me says it is not a complete load issue...it seems more like a pathing issue...like it can't find it the first time, but anything after that works.

(But I have to leave the sounds external to keep the overall size down, the server people are having a cow even 'thinking' about a flash file.)

Please let me know if I am explaining that correctly. It is very frustrating.

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Here's a sample with the code I am using....


This sample has same issue as the final file is having, prolly cause this is the file I built as practice. It has a swf and the fla and the audio folder.

(I tried to post it just on line, but then NONE of the sounds ever worked. This is totally confusing me.)

Buffy

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Trying to avoid streaming...the network guys have a heart attack when you say streaming.

But, even in experiments with that...the code seems to stall on first try and never gets to the "sound.onLoad= function(success:Boolean)". I have used trace and this is where the whole thing breaks first time.

(ps...forgot to mention this error happens when running the SWF outside of Flash...ctl/enter seems to work 90% of time)

Dave

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
> Trying to avoid streaming...the network guys have a heart attack when you say streaming.

Don't say it.

By the way it worked for me if I set the streaming to true (in the standalone player).

Kenneth Kawamoto
 
Yeah, and I may have to go that way. Another programmer here found that just a bit ago to...

What is weird is, even with that set up, if you put a trace in after the sound.onload...it isn't triggered the first time. The sound plays, but the code dies for some reason..

(Just got back from the meeting where network guy tried to tell me a 400k video was too much of a bandwidth hit on his network....some people...)

Dave

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top