Home Tutorial Flex Flex4 Components Spark CrossFade Effect in Flex4

 
 

Share on Google+Share on Google+
Spark CrossFade Effect in Flex4
Posted on: July 6, 2010 at 12:00 AM
Advertisement
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>

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

chromeColor="#000000"

color="#CCCCCC"

height="256"

width="407">

<mx:ApplicationControlBar horizontalAlign="center"

width="405">

<s:Button id="btn"

label="CrossFade Effect"

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

<s:Button id="btn1"

label="Stop Effect"

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

</mx:ApplicationControlBar>

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

x="89" y="40"

color="#000000"

fontFamily="Verdana"/>

<mx:Image id="myImage"

source="{Image1}"

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

</s:Panel>

</s:Application>

Output:

Running Application:

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

Download this code

Advertisement

Related Tags for Spark CrossFade Effect in Flex4:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 6, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com