Пример ниже расскажет о том, как проиграть встроенный MP3 при отображении алерта (Alert)
используя creationCompleteEffect стиль/эффект
View CodeMXML | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <?xml version="1.0" encoding="utf-8"?> <mx:Application name="Alert_creationCompleteEffect_test_2" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Script> <![CDATA[ import mx.controls.Alert; [Embed("assets/iconCritical.png")] private var IconCritical:Class; private function showAlert():void { var message:String = "The quick brown fox jumped over the lazy dog."; var title:String = "Alert title"; var a:Alert = Alert.show(message, title, Alert.OK, null, null, IconCritical); a.status = Capabilities.version; a.isPopUp = false; } ]]> </mx:Script> <mx:Style> Alert { creationCompleteEffect: ding; } </mx:Style> <mx:SoundEffect id="ding" source="@Embed('assets/ding.mp3')" useDuration="false" /> <mx:Button id="button" label="Launch Alert" click="showAlert();" /> </mx:Application> |
также можно внедрить MP3, создать SoundEffect и установить creationCompleteEffect в ActionScript, как в следующем примере:
View CodeMXML | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <?xml version="1.0" encoding="utf-8"?> <mx:Application name="Alert_creationCompleteEffect_test_2" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" initialize="init();"> <mx:Script> <![CDATA[ import mx.effects.SoundEffect; import mx.controls.Alert; [Embed("assets/iconCritical.png")] private const IconCritical:Class; [Embed("assets/ding.mp3")] private const DingSoundEffect:Class; private var ding:SoundEffect; private function init():void { ding = new SoundEffect(); ding.source = DingSoundEffect; ding.useDuration = false; } private function showAlert():void { var message:String = "The quick brown fox jumped over the lazy dog."; var title:String = "Alert title"; var a:Alert = Alert.show(message, title, Alert.OK, null, null, IconCritical); a.setStyle("creationCompleteEffect", ding); a.status = Capabilities.version; a.isPopUp = false; } ]]> </mx:Script> <mx:Button id="button" label="Launch Alert" click="showAlert();" /> </mx:Application> |

0 Отзывов на “Звуковое сопровождение алерта (Alert) Flex”
Оставить отзыв