1 Reply Latest reply on Dec 12, 2010 11:08 AM by Shongrunden

    Play a sound during a state transition




      I would like to associate a sound with a transition so that it is played during the duration of the transition.

      What is the best way to do that in flex Hero?


      Thank you.

        • 1. Re: Play a sound during a state transition
          Shongrunden Adobe Employee

          You might find the SoundEffect class useful, for example:

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



                    title="Sound Effect">



                    <s:State name="state1"/>

                    <s:State name="state2"/>




                    <s:Button label="toggle state" click="currentState=currentState=='state1'?'state2':'state1'" />




                    <s:Transition fromState="*" toState="*">


                              <s:Parallel target="{target}">

                                   <s:Fade />

                                   <mx:SoundEffect duration="1000" source="mySound.mp3"/>






               <s:Button id="target" label="target" width="100" height="100" verticalCenter="0" horizontalCenter="0"

                           alpha.state1="1" alpha.state2="0.5"/>