加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex中调用嵌入声音效果的三种方法

发布时间:2020-12-15 01:19:42 所属栏目:百科 来源:网络整理
导读:?①、使用mx:SoundEffect /标签,@Embed, mouseDownEffect ?xml version="1.0" encoding="utf-8"?mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" mx:Script ![CDATA[ import m

?①、使用<mx:SoundEffect />标签,@Embed,mouseDownEffect

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            private var alert:Alert;

            private function showAlert():void {
                alert = Alert.show("Are you sure you want to delete the internet?","Confirm delete...",Alert.YES | Alert.NO);
            }
        ]]>
    </mx:Script>

    <mx:SoundEffect id="soundEffect" source="@Embed(source='assets/ding.mp3')" />

    <mx:Button label="Delete Internet?" click="showAlert();" mouseDownEffect="{soundEffect}" />

</mx:Application>

?

②、使用 [Embed],<mx:SoundEffect /> ,mouseDownEffect

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            private var alert:Alert;

            private function showAlert():void {
                alert = Alert.show("Are you sure you want to delete the internet?",Alert.YES | Alert.NO);
            }
        ]]>
    </mx:Script>

    <mx:SoundEffect id="soundEffect" source="@Embed(source='assets/ding.mp3')" />

    <mx:Button label="Delete Internet?" click="showAlert();" mouseDownEffect="{soundEffect}" />

</mx:Application>


?

③、使用[Embed],SoundAsset类,SoundAsset.play()事件

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.core.SoundAsset;
 
            [Embed('assets/ding.mp3')]
            private var ding_mp3:Class;
 
            private var ding:SoundAsset = new ding_mp3() as SoundAsset;
 
            private var alert:Alert;
 
            private function showAlert():void {
                alert = Alert.show("Are you sure you want to delete the internet?",Alert.YES | Alert.NO);
            }
        ]]>
    </mx:Script>
 
    <mx:Button label="Delete Internet?" click="showAlert(); ding.play()" />
 
</mx:Application>


原文地址:http://blog.minidx.com/2008/07/19/1091.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读