接下来的例子演示了Flex中如何替换掉CheckBox的默认图标,创建具有自己风格CheckBox控件。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
-
- <mx:Style>
- CheckBox {
- /* Unselected icons */
- upIcon: Embed(source="assets/bullet_red.png");
- overIcon: Embed(source="assets/bullet_red.png");
- downIcon: Embed(source="assets/bullet_yellow.png");
- /* Selected icons */
- selectedUpIcon: Embed(source="assets/bullet_green.png");
- selectedOverIcon: Embed(source="assets/bullet_green.png");
- selectedDownIcon: Embed(source="assets/bullet_yellow.png");
- }
- </mx:Style>
-
- <mx:CheckBox id="cheezburger"
- label="I can has cheezburger?"
- fontSize="12"
- fontWeight="bold" />
-
- </mx:Application>