<Flex 3 常见组件使用技巧系列>将持续更新一些本人在网上看到的,学到的一些不错实用的 Flex 实例 ,配合简单的讲解和完整的代码。希望有一些参考价值。本系列持续更新中,建议收藏此页,以便随时翻看 。
Alert 组件:
在Flex中使用StyleMaager类和setStyle()方法给Alert组件设置样式
在Flex中使用StyleMaager类和setStyle()方法给Alert组件设置样式
下面的实例演示了怎样利用 StyleManager.getStyleDeclaration() 方法和 setStyle() 给一个 Flex Alert组件设置样式
先看演示:
代码:
先看演示:
代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.styles.StyleManager;
private var alert:Alert;
private var alertCSS:CSSStyleDeclaration;
private function init():void {
alertCSS = StyleManager.getStyleDeclaration("Alert");
}
private function showAlert(color:Object):void {
alertCSS.setStyle("modalTransparencyColor", color);
alertCSS.setStyle("themeColor", color);
alert = Alert.show("The quick brown fox...");
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Button label="Red"
themeColor="red"
click="showAlert('red');" />
<mx:Button label="Orange"
themeColor="haloOrange"
click="showAlert('haloOrange');" />
<mx:Button label="Yellow"
themeColor="yellow"
click="showAlert('yellow');" />
<mx:Button label="Green"
themeColor="haloGreen"
click="showAlert('haloGreen');" />
<mx:Button label="Blue"
themeColor="haloBlue"
click="showAlert('haloBlue');" />
</mx:ApplicationControlBar>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.styles.StyleManager;
private var alert:Alert;
private var alertCSS:CSSStyleDeclaration;
private function init():void {
alertCSS = StyleManager.getStyleDeclaration("Alert");
}
private function showAlert(color:Object):void {
alertCSS.setStyle("modalTransparencyColor", color);
alertCSS.setStyle("themeColor", color);
alert = Alert.show("The quick brown fox...");
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Button label="Red"
themeColor="red"
click="showAlert('red');" />
<mx:Button label="Orange"
themeColor="haloOrange"
click="showAlert('haloOrange');" />
<mx:Button label="Yellow"
themeColor="yellow"
click="showAlert('yellow');" />
<mx:Button label="Green"
themeColor="haloGreen"
click="showAlert('haloGreen');" />
<mx:Button label="Blue"
themeColor="haloBlue"
click="showAlert('haloBlue');" />
</mx:ApplicationControlBar>
</mx:Application>
Alert组件显示多个按钮以及设置Icon的一些技巧
本文逐步深入的讲解Flex中Alert组件使用中的一些技巧
让我们先从最简单的例子说起。 这只比 Alert.show("需要显示的文字") 复杂一点点
1 . Alert显示多个按钮
看演示:
代码:
让我们先从最简单的例子说起。 这只比 Alert.show("需要显示的文字") 复杂一点点
1 . Alert显示多个按钮
看演示:
点这里 显示/隐藏 媒体
代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
fontSize="12"
>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var alert:Alert;
private function showAlert():void {
var text:String = "这里我们让他显示两个按钮";
var title:String = "This is the title of the Alert window";
alert = Alert.show(text, title, Alert.YES | Alert.NO);
}
]]>
</mx:Script>
<mx:Button label="Alert.show()" click="showAlert();" />
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
fontSize="12"
>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var alert:Alert;
private function showAlert():void {
var text:String = "这里我们让他显示两个按钮";
var title:String = "This is the title of the Alert window";
alert = Alert.show(text, title, Alert.YES | Alert.NO);
}
]]>
</mx:Script>
<mx:Button label="Alert.show()" click="showAlert();" />
</mx:Application>