To really finish off our relational network and to add strength to our animation, this recipe is going to add sounds to it all.
Open the files downloaded from the Packt Publishing website for Chapter 8 | Recipe 6 to follow along.
The following are the steps to add sounds to a relational network:
In a Flash file (
.fla
), add four sounds for rollover, click, animation in, and animation out.Export that file as a
.swc
file.In FlashDevelop, right-click on the
.swc
file and choose Add to Library.In
PlusButton.as
, add a listener for theMouseEvent.ROLL_OVER
event and for theMouseEvent.CLICK
event.Add the corresponding functions:
private function _onMouseClick(event:MouseEvent):void { _soundClick.play(0,0,new SoundTransform(2)); } private function _onRollOver(event:MouseEvent):void { _soundOver.play(0,0,new SoundTransform(0.75)); }
Repeat steps 4 and 5 in
MinusButton.as
.In
RelationalNetwork.as
, initialize the animate in and the animate out sounds, as shown...