---
title: "组件逐渐消失效果实例"
author: "convolute"
date: "2010-06-17T16:35:53Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2010-06-17T16:36:11Z"
id: 693219
url: "https://convolute.iteye.com/blog/693219"
---

```
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
					   xmlns:s="library://ns.adobe.com/flex/spark" 
					   xmlns:mx="library://ns.adobe.com/flex/mx">
	<s:layout>
		<s:BasicLayout/>
	</s:layout>
	<s:states>
		<s:State name="state1"/>
		<s:State name="state2"/>
	</s:states>
	<!-- Transition用于在State转换是执行Fade特效。 -->
	<s:transitions>
		<s:Transition>
			<!-- 表示Fade的对象是这3个对象 -->
			<s:Fade targets="{[button0,button1,label2]}"/>
		</s:Transition>
	</s:transitions>
	<fx:Declarations>
		<!-- 将非可视元素（例如服务、值对象）放在此处 -->
		
				 
	</fx:Declarations>
	<s:Button id="button0" label="按钮1" x="100" y="0" visible="true" visible.state2="false"/>
	<s:Button id="button1" label="按钮2" x="100" y="50" alpha="0" alpha.state2="1"/>
	<s:Label id="label2" text="标签3" x="100" y="100" includeIn="state2"/>
	<s:Button label="Toggle State" click="currentState = (currentState=='state1')?'state2':'state1'"/>
</s:WindowedApplication>
```

 

![](/upload/picture/pic/65287/baf9de9c-af64-39be-98fe-dc02a5bc0356.jpg)

图一  
![](/upload/picture/pic/65285/f283086d-5eb2-3ef5-90df-d6ca053b123c.jpg)

图二