Flex4学习笔记(五)--相关特效的使用

1.制作文字淡入淡出效果

	<fx:Script>
		<![CDATA[
			protected function button1_clickHandler(event:MouseEvent):void
			{
				label1.visible = !label1.visible;
			}
		]]>
	</fx:Script>

	<fx:Declarations>
		<s:Fade id="fadeOut" duration="1000" alphaFrom="1.0" alphaTo="0.0"/>  
		<s:Fade id="fadeIn" duration="1000" alphaFrom="0.0" alphaTo="1.0"/>
		
		
	</fx:Declarations>
	
	<mx:Label text="hello world!" id="label1" fontSize="16" hideEffect="{fadeOut}" showEffect="{fadeIn}" x="126" y="39" fontWeight="bold"/>  
	<s:Button x="227" y="38" label="按钮" click="button1_clickHandler(event)"/>

 

2.制作文字滚动效果

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)">

	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;

			protected function application1_creationCompleteHandler(event:FlexEvent):void
			{
				moveit.yFrom = label1.y;
				moveit.yTo = label1.y + 200;
				moveit.repeatCount = 1;
				moveit.repeatDelay = 0;
				moveit.duration = 5000;
				moveit.play();
			}


			protected function label1_mouseOverHandler(event:MouseEvent):void
			{
				moveit.pause();
			}


			protected function label1_mouseOutHandler(event:MouseEvent):void
			{
				moveit.resume();
			}

		]]>
	</fx:Script>

	<fx:Declarations>
		<s:Move id="moveit" target="{label1}" />
	</fx:Declarations>
		<s:Label id="label1" text="这是一个测试" fontSize="16" x="186" y="78" mouseOver="label1_mouseOverHandler(event)" mouseOut="label1_mouseOutHandler(event)" />
</s:Application>

 

3.制作文字阴影效果

	<fx:Declarations>
		<s:DropShadowFilter id="dropShadow" alpha="0.35" blurX="6" blurY="6" distance="6" color="#000000" angle="90" />  
	</fx:Declarations>

	<s:Label x="354" y="87" text="这是一个测试" fontSize="32" filters="{dropShadow}" />
posted @ 2010-08-15 00:15  魔豆  阅读(1966)  评论(0编辑  收藏  举报