Home Tutorial Flex Flex4 Components MX Sound Effect in Flex4

 
 

Share on Google+Share on Google+
MX Sound Effect in Flex4
Posted on: June 30, 2010 at 12:00 AM
Advertisement
The Sound Effect plays an mp3 file when you perform an event. You will use the source property for specify the mp3 file.

MX Sound Effect in Flex4:

The Sound Effect plays an mp3 file when you perform an event. You will use the source property for specify the mp3 file. The tag of Sound Effect is <mx:SoundEffect>. The syntax is following:

<mx:SoundEffect
id="ID"
autoLoad="true|false"
bufferTime="1000"
loops="0"
panEasingFunction=""
panFrom="0"
source=""
startTime="0"
useDuration="true|false"
volumeEasingFunction="true|false"
volumeTo="1"/>

In this example you can see how we can use a Sound Effect in your application.

Example:

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

minWidth="955" minHeight="600">

<fx:Declarations>

<mx:SoundEffect id="mp3sound"

source="@Embed(source='file:/C:/work/bikrant/mp3/Best_Guitar_Tone_201.mp3')"

useDuration="false" loops="0"/>

</fx:Declarations>

<s:Panel title="MX Sound Effect Example"

width="487" height="228"

chromeColor="#000000" color="#CCCCCC">

<mx:ApplicationControlBar width="485" horizontalAlign="center">

<s:Label text="Click on image and show the effect."

fontFamily="verdana" color="#000000"/>

</mx:ApplicationControlBar>

<mx:Image id="roseindia"

source="@Embed(source='file:/C:/work/bikrant/image/player.png')"

x="179" y="44"

mouseDownEffect="{mp3sound}"

width="128" height="128"/>

</s:Panel>

</s:Application>

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Advertisement

Related Tags for MX Sound Effect in Flex4:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 30, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com