Flex - 向右擦除效果



簡介

WipeRight 類定義了一個向右擦除的效果。元件的之前或之後狀態必須不可見。

類宣告

以下是 **mx.effects.WipeRight** 類的宣告:

public class WipeRight
   extends MaskEffects

公共方法

序號 方法及描述
1

WipeRight(target:Object = null)

建構函式。

繼承的方法

此類繼承自以下類的方法:

  • mx.effects.MaskEffect
  • mx.effects.Effect
  • flash.events.EventDispatcher
  • Object

Flex 向右擦除效果示例

讓我們按照以下步驟來檢查在 Flex 應用程式中使用 WipeRight 效果,方法是建立一個測試應用程式:

步驟 描述
1 建立一個名為 *HelloWorld* 的專案,放在 *com.tutorialspoint.client* 包下,如“Flex - 建立應用程式”一章中所述。
2修改 *HelloWorld.mxml*,如下所述。保持其餘檔案不變。
3 編譯並執行應用程式,以確保業務邏輯按要求工作。

以下是修改後的 mxml 檔案 **src/com.tutorialspoint/HelloWorld.mxml** 的內容。

<?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
   width = "100%" height = "100%" minWidth = "500" minHeight = "500">
   
   <fx:Style source = "/com/tutorialspoint/client/Style.css" />
   <fx:Script>
      <![CDATA[
         protected function btnWipeRight_clickHandler
            (event:MouseEvent):void {			
            imageFlex.visible = true;
         }
      ]]>
   </fx:Script>
   
   <fx:Declarations>
      <mx:WipeRight id = "wipeRight" duration = "2000" />
   </fx:Declarations>
   
   <s:BorderContainer width = "630" height = "480" id = "mainContainer" 
      styleName = "container">
      <s:VGroup width = "100%" height = "100%" gap = "50" 
         horizontalAlign = "center" verticalAlign = "middle">
         
         <s:Label id = "lblHeader" text = "Effects Demonstration" 
            fontSize = "40" color = "0x777777" styleName = "heading" />
         <s:Panel id = "wipeRightPanel" title = "Using WipeRight Effect" 
            width = "500" height = "300" includeInLayout = "true" visible = "true">
            
            <s:layout>
               <s:VerticalLayout  gap = "10" verticalAlign = "middle" 
                  horizontalAlign = "center" />
            </s:layout>			
            
            <mx:Image id = "imageFlex" visible = "{false}" 
               source = "https://tutorialspoint.tw/images/flex-mini.png" 
               showEffect = "{wipeRight}" />
            
            <s:Button id = "btnWipeRight" label = "Wipe Right" 
               click = "btnWipeRight_clickHandler(event)" />            
          </s:Panel>
       </s:VGroup>	 
    </s:BorderContainer>	
</s:Application>

準備好所有更改後,讓我們像在Flex - 建立應用程式一章中一樣,在普通模式下編譯並執行應用程式。如果您的應用程式一切正常,它將產生以下結果:[ 線上試用 ]

Flex WipeRight Effect
flex_visual_effects.htm
廣告

© . All rights reserved.