Skip to main content
Known Participant
April 20, 2011
Question

Rollover buttons to play sound using "loadSound"

  • April 20, 2011
  • 1 reply
  • 2509 views

Hi, there

I am seeking help with the following AS2 code. The target effect: Rolling over each of the two buttons on the main stage plays different sound. The code below works. However, I need to embed it in another application (Articulate) which doesnot allow the use of "_root" and "attachSound". I was recommended to use "loadSound" instead. However, not a coding person, I am at a loss.

Can anyone help me to change the script below to remove "_root" and "attachSound" and use "loadSound" instead? Thanks so much!

var mySound:Sound = new Sound();
mcButton5.onRollOver = function() {
_root.mySound.attachSound("sound1");
_root.mySound.start();

var mySound:Sound = new Sound();
mcButton6.onRollOver = function() {
_root.mySound.attachSound("sound2");
_root.mySound.start();

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 20, 2011

why can't you use attachSound?  that's not likely correct because attachSound() has been supported since flash 5.

what you need to do is use:

this._lockroot=true;  // so you can still use _root in your file

and you need to change your sound instantiation to use:

var mySound:Sound=new Sound(this);

maple2009Author
Known Participant
April 21, 2011

Kglad

Thanks a lot for your quick help! I tried the code. The SWF played well, but after it was embeded into another application (Articulate), the sound is missing.... Not sure what I could do differently...

kglad
Community Expert
Community Expert
April 21, 2011

did you make BOTH of those changes?