Topic: Adding sound to thumbnails or next/prev arrows

How do I add a sound for an onRelease event for e.g. clicking on a thumbnail or the previous/next arrows to navigate the thumbnails?

I tried the following but Flash generated an error report:
1) importing a wav file into simpleviewer.fla
2) Set the sound linkage identifier as 'bleep'
3) In RolloverButton.as, I modified the following (denoted in red):

public function onRelease(){
   mySound = new Sound(this);
   mySound.attachSound("bleep");
   mySound.start(0, 1);

   if (!mEnabled) return;
   mClip_mc._x -= mClickShift;
   mClip_mc._y -= mClickShift;
   doAction();               
}   

When I republished viewer.sef, Flash reported an error and mentioned:

"There is no method with the name 'mySound'."

Please advise.

Rgds,
Dan

Re: Adding sound to thumbnails or next/prev arrows

Airtight Team,

any insight you provide will be greatly appreciated.

Rgds,
Dan

Re: Adding sound to thumbnails or next/prev arrows

add 'var' in front of ' mySound = new Sound(this); '.

Felix Turner
SimpleViewer Support Team.

Re: Adding sound to thumbnails or next/prev arrows

Thanks for the tip, Felix.

I added 'var' before 'mySound = new Sound(this);' and the swf published without problems. But there's no sound event when I click on any of the buttons.

I double-checked the sound linkage identifier in the simpleviewer.fla source file and it corresponds to the one specified in the .as file.

Have I overlooked anything from this script?

public function onRelease(){
var mySound = new Sound(this);
mySound.attachSound("bleep");
mySound.start(0, 1);

if (!mEnabled) return;
mClip_mc._x -= mClickShift;
mClip_mc._y -= mClickShift;
doAction();
}

I tried different permutations e.g. play sound on rollOver, etc and still there's no sound.

Are there other bits to address before I can get the sound event to happen?

Please advise.

Rgds,
Dan

Re: Adding sound to thumbnails or next/prev arrows

1) change this:

var mySound = new Sound(this);

to this:

var mySound = new Sound(mClip_mc);


2) make sure the sound symbol is set to export in first frame.

Felix Turner
SimpleViewer Support Team.

Re: Adding sound to thumbnails or next/prev arrows

IT WORKS! Thanks, Felix.  big_smile

I also used the same method to add a sound event to thumbnails. I'll share the info with others.

If anyone else wants add a (onRelease) sound event to the thumbnail navigation arrow buttons or to the thumbnails themselves, do the following:

1) Import a sound file (e.g. click.wav) into simpleviewer.fla. In the LIBRARY window, right-click click.wav and select LINKAGE.

2) Tick the options EXPORT FOR ACTIONSCRIPT and EXPORT IN FIRST FRAME. In the IDENTIFIER entry, give it a name e.g. clicksound. Remember this identifier name.

3) To add a sound event to the thumbnail navigation arrow (same script works for NEXT and PREV arrows), open RolloverButton.as. Scroll down until you see the following actionscript:

    public function onRelease(){
        if (!mEnabled) return;
        mClip_mc._x -= mClickShift;
        mClip_mc._y -= mClickShift;
        doAction();                
    }

Insert the following (denoted in red) into the actionscript above:

    public function onRelease(){
        var mySound = new Sound(mClip_mc);
        mySound.attachSound("clicksound");
        mySound.start(0, 1);

        if (!mEnabled) return;
        mClip_mc._x -= mClickShift;
        mClip_mc._y -= mClickShift;
        doAction();               
    }

4) To add a sound event to the thumbnails, open Thumb.as. Scroll down until you see the following actionscript:

    private function onRelease(){
        if (mSelected ) return;
        mBase_mc._x -= Options.thumbnailClickShift;
        mBase_mc._y -= Options.thumbnailClickShift;
        mThumbArea.selectedThumbIndex =  mIndex;
                    
    }

Insert the following (denoted in red) into the actionscript above:

    private function onRelease(){
        var mySound = new Sound(mClip_mc);
        mySound.attachSound("clicksound");
        mySound.start(0, 1);

        if (mSelected ) return;
        mBase_mc._x -= Options.thumbnailClickShift;
        mBase_mc._y -= Options.thumbnailClickShift;
        mThumbArea.selectedThumbIndex =  mIndex;
                   
    }

5) Save both .as files. Return to simpleviewer.fla and republish viewer.swf. Play viewer.swf and the sound event(s) should happen.

Hope the info helps.

Rgds,
Dan