Flex中如何通过creationCompleteEffect样式使Alert对话框显示的时候播放嵌入的MP3文件的例子

By Minidxer | September 10, 2008

接下来的例子演示了Flex中如何通过creationCompleteEffect样式,使Alert对话框显示的时候播放嵌入的MP3文件。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application name="Alert_creationCompleteEffect_test_2"
  3.         xmlns:mx="http://www.adobe.com/2006/mxml"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white">
  7.  
  8.     <mx:Script>
  9.         <![CDATA[
  10.             import mx.controls.Alert;
  11.  
  12.             [Embed("assets/iconCritical.png")]
  13.             private var IconCritical:Class;
  14.  
  15.             private function showAlert():void {
  16.                 var message:String = "The quick brown fox jumped over the lazy dog.";
  17.                 var title:String = "Alert title";
  18.                 var a:Alert = Alert.show(message,
  19.                             title,
  20.                             Alert.OK,
  21.                             null,
  22.                             null,
  23.                             IconCritical);
  24.                 a.status = Capabilities.version;
  25.                 a.isPopUp = false;
  26.             }
  27.         ]]>
  28.     </mx:Script>
  29.  
  30.     <mx:Style>
  31.         Alert {
  32.             creationCompleteEffect: ding;
  33.         }
  34.     </mx:Style>
  35.  
  36.     <mx:SoundEffect id="ding"
  37.             source="@Embed('assets/ding.mp3')"
  38.             useDuration="false" /> 
  39.  
  40.     <mx:Button id="button"
  41.             label="Launch Alert"
  42.             click="showAlert();" />
  43.  
  44. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Flex | Tags: , ,

Related Post

Leave a Comment

Name(*):

E-Mail(*) :

Website :

Comments :

Search Posts

Archives

Sponsored Ads