# Sound object problem

**URL:** <https://forum.kirupa.com/t/sound-object-problem/7838>\
**Category:** Uncategorized\
**Created:** [November 8, 2002, 7:51pm UTC](https://forum.kirupa.com/t/sound-object-problem/7838 "2002-11-08T19:51:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![waffe](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@waffe](https://forum.kirupa.com/u/waffe)\
**Post date:** [November 8, 2002, 7:51pm UTC](https://forum.kirupa.com/t/sound-object-problem/7838/1 "2002-11-08T19:51:38Z")

</div>

I have this code;

stop();  
bsig = 0;  
screen = new Sound(this);  
screen.loadSound(“burnout.mp3”, true);  
time = screen.duration;

function sPos(aus, sobj) {  
this[aus] = this[sobj].position;  
}  
// Anzeige Balken in Prozent  
function s(obj, spobj) {  
length = this[spobj].duration;  
pos = this[spobj].position;  
percent = pos\*100/length;  
\_root[obj].\_xscale = percent;  
percent = parseInt()+"%";  
} ect…

Sorry it was in german and I’m not finished translating, but that is not the point.

This code works just fine, there is a seconds counter and a bytes loaded and all kinds of other great stuff.

But now I change

screen.loadSound(“burnout.mp3”, true);

to

onChange = function ()  
{ screen.loadSound(listbox.getSelectedItem().data[“Link”], true);};

And the whole thing falls apart. I still here music but the code above is not working, its not reading the screen = newSound or something, Because the seconds counter and bytes loaded stay at 0.

Any thoughts

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 8, 2002, 7:54pm UTC](https://forum.kirupa.com/t/sound-object-problem/7838/2 "2002-11-08T19:54:50Z")

</div>

if you created your sound object in the first function, it may not be available in the second. Check your debugger for values. It all depends on how you load your objects and when you call your functions.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 8, 2002, 8:06pm UTC](https://forum.kirupa.com/t/sound-object-problem/7838/3 "2002-11-08T20:06:18Z")

</div>

you said;

if you created your sound object in the first function, it may not be available in the second.

What do you mean by sound object first function/ second function,  
I only see one sound object.

screen = new Sound(this); :q:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 8, 2002, 9:05pm UTC](https://forum.kirupa.com/t/sound-object-problem/7838/4 "2002-11-08T21:05:55Z")

</div>

that is to say…

load your sound object within this function

```auto

onChange = function () {
screen=new sound(this??) //where will it load the sound object?

screen.loadSound(listbox.getSelectedItem().data["Link"], true);};

```

I think that will work for you… but don’t know if it serves your purpose.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2002, 2:52am UTC](https://forum.kirupa.com/t/sound-object-problem/7838/5 "2002-11-09T02:52:28Z")

</div>

The on change function works, but other function like

\_root.screen.onSoundComplete = function() {

Does not work. It is as the onSoundComplete = function does not see the sound object screen.

Hmmm.

:-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2002, 2:56am UTC](https://forum.kirupa.com/t/sound-object-problem/7838/6 "2002-11-09T02:56:39Z")

</div>

probably the same reason. See, some of these things are quirky (to me, anyway). If you use a sound object inside a function, try to set everything that you will do with that object inside that function and it is almost sure to work. If you try to call the screen object from within another function, it most likely will not see it. For example… \_root.screen doesnt really exist, until it is called by the function that happens to be in the root. Does that make sense?

Others may have had a different experience with this…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2002, 3:04am UTC](https://forum.kirupa.com/t/sound-object-problem/7838/7 "2002-11-09T03:04:01Z")

</div>

Its the same problem from the begining of this thread. The Sound object exists for one function but not another. :\*(

Like you said before it may be how/when I load the sound object.

I’m gointg to crack it open and give it one more shot.:rambo:
