DrunkenOrc
105 posts
|
Alright, to be frank, I have no idea how to make a sound play from inside of a class.
class RedTower extends MovieClip {
var lowbuzz:Sound;
function onLoad() {
lowbuzz.attachSound('lowbuzz');
}
function onEnterFrame() {
if (this.hitTest(_root.TheCharacter._x, _root.TheCharacter._y, true)) {
_root.TheCharacter.redtouch = true;
// The above line has nothing to do with the sound.
lowbuzz.start(0, 1);
}
}
}
I patched together this sound emmiting code from some AS2 tutorials and it doesn’t work. Frankly, I’m not supprised. Can anyone give me a hand?
|
|
|
Cloud_9ine
2242 posts
|
Well although in AS3, Colby made a real nice sound managing class here I made one in AS3 also with some advanced looping functionality, but if you look at Colby’s source you could probably get the gist. Unless sound in AS2 is completely different from AS3.
|
|
|
jonathanasdf
1592 posts
|
try using another var other than lowbuzz for the var name.
and cloud, that is pretty offtopic from his question. But anyways I made a similar sound managing class myself too, with crossfading :)
|
|
|
Cloud_9ine
2242 posts
|
Well yea its a bit off topic, I was merely suggesting he look as Colby’s source for some hints because I was too lazy to write it out.
Oh yea, mine, although isn’t quite made to, can crossfade, AND set keys/buttons for individual sound effect and music muting.
|
|
|
jonathanasdf
1592 posts
|
same >:(
Anyways, yeah I see. But it doesn’t help because as2 and as3 is completely different, and he isn’t looking for a manager class.
|
|
|
DrunkenOrc
105 posts
|
I tried changing the var name to hitnoise, but that did nothing.
class RedTower extends MovieClip {
var hitnoise:Sound;
function onLoad() {
hitnoise.attachSound('lowbuzz');
}
function onEnterFrame() {
if (this.hitTest(_root.TheCharacter._x, _root.TheCharacter._y, true)) {
_root.TheCharacter.redtouch = true;
hitnoise.start(0, 1);
}
}
}
Any other ideas?
|
|
|
Cloud_9ine
2242 posts
|
Your sure the linkage of the sound is ‘lowbuzz’? That often screws me over so badly sometimes. Damn I’m so bored.
Also set it up so it will play a sound right away instead of waiting for the condition to play it. So maybe put the play on the enterframe. Sure it will sound ugly but it will tell you if its the sound or the if.
|
|
|
jonathanasdf
1592 posts
|
EDIT
LOLOLOL cannot believe I didn’t see this.
You never instantiated hitnoise. put hitnoise = new Sound() somewhere.
|
|
|
Cloud_9ine
2242 posts
|
ROFL, I should have noticed that too, but liek I said, I’m lazy. But yea. Either way, I suggest if you go on to AS3, to us a nice little sound engine for all your sound work, it’s so simple and organized. :P
|
|
|
DrunkenOrc
105 posts
|
Ah, that was the problem. Thank you.
|
|
|
Cloud_9ine
2242 posts
|
My Sound manager is still better. It (mostly) implements Urbansqualls coding standards.
|