Spark CrossFade Effect in Flex4


 

Spark CrossFade Effect in Flex4

The Spark CrossFade Effect is used for change the component one by one.

The Spark CrossFade Effect is used for change the component one by one.

Spark CrossFade Effect in Flex4:

The Spark CrossFade Effect is used for change the component one by one. When a component change it will be fade after that another component will be shown. The tag of CrossFade Effect is <s:CrossFade>. The syntax of CrossFade is following:

<s:CrossFade
id=""
target=""
bitmapFrom=""
bitmapTo=""
repeatCount=""
repeatBehavior=""
duration=""
/>

In this example you can see how we can use CrossFade Effect in your application.

Example:

<?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">

<fx:Script>

<![CDATA[

import mx.core.BitmapAsset;

[Embed(source='file:/C:/work/bikrant/image/bridge.png')]

[Bindable]

public var Image1:Class;

[Bindable]

public var image1Bitmap:BitmapAsset = new Image1();

[Embed(source='file:/C:/work/bikrant/image/compass.png')]

[Bindable]

public var Image2:Class;

[Bindable]

public var image2Bitmap:BitmapAsset = new Image2();

]]>

</fx:Script>

<fx:Declarations>

<s:CrossFade id="CrossFadeEffect"

target="{myImage}"

bitmapFrom="{image1Bitmap.bitmapData}"

bitmapTo="{image2Bitmap.bitmapData}"

repeatCount="0"

repeatBehavior="reverse"

duration="1000"/>

</fx:Declarations>

0

<s:Panel title="Spark CrossFade Effect Example"

chromeColor="#000000"

color="#CCCCCC"

1

height="256"

width="407">

<mx:ApplicationControlBar horizontalAlign="center"

2

width="405">

<s:Button id="btn"

label="CrossFade Effect"

3

click="{CrossFadeEffect.end();CrossFadeEffect.play();}"/>

<s:Button id="btn1"

label="Stop Effect"

4

click="{CrossFadeEffect.stop();}"/>

</mx:ApplicationControlBar>

<s:Label text="Click on Buttons for showing the effect"

5

x="89" y="40"

color="#000000"

fontFamily="Verdana"/>

6

<mx:Image id="myImage"

source="{Image1}"

x="131" y="65"/>

7

</s:Panel>

</s:Application>

Output:

8

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

9

Ads