Share on Google+Share on Google+

Spark KeyFrames Effect in Flex4

Ads
The keyframe defines the value of a property at a specific time during the effect.

Spark KeyFrames Effect in Flex4:

The keyframe defines the value of a property at a specific time during the effect. If your effect has just two keyframes use the Animate effect. The Animate effect has the staring and ending value for the property corresponding to two keyframes. The tag of KeyFrame is <s:KeyFrame>. The syntax of KeyFrame is following:

<s:KeyFrame
time=""
value=""
/>

In this example you can see how we can use the keyFrame 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:Declarations>

<s:AnimateTransform id="keyframeEffect"

target="{footballImage}">

<s:motionPaths>

<s:MotionPath property="translationX" >

<s:keyframes>

<s:Keyframe time="250" value="0"/>

<s:Keyframe time="500" value="50"/>

<s:Keyframe time="750" value="100"/>

<s:Keyframe time="1000" value="150"/>

<s:Keyframe time="1250" value="200"/>

<s:Keyframe time="1500" value="250"/>

<s:Keyframe time="1750" value="300"/>

<s:Keyframe time="2000" value="350"/>

<s:Keyframe time="2250" value="300"/>

<s:Keyframe time="2500" value="250"/>

<s:Keyframe time="2750" value="200"/>

<s:Keyframe time="3000" value="150"/>

<s:Keyframe time="3250" value="100"/>

<s:Keyframe time="3500" value="50"/>

<s:Keyframe time="3750" value="0"/>

</s:keyframes>

</s:MotionPath>

<s:MotionPath property="translationY" >

<s:keyframes>

<s:Keyframe time="250" value="0"/>

<s:Keyframe time="500" value="150"/>

<s:Keyframe time="750" value="0"/>

<s:Keyframe time="1000" value="150"/>

<s:Keyframe time="1250" value="0"/>

<s:Keyframe time="1500" value="150"/>

<s:Keyframe time="1750" value="0"/>

<s:Keyframe time="2000" value="150"/>

<s:Keyframe time="2250" value="0"/>

<s:Keyframe time="2500" value="150"/>

<s:Keyframe time="2750" value="0"/>

<s:Keyframe time="3000" value="150"/>

<s:Keyframe time="3250" value="0"/>

<s:Keyframe time="3500" value="150"/>

<s:Keyframe time="3750" value="77"/>

</s:keyframes>

</s:MotionPath>

</s:motionPaths>

</s:AnimateTransform>

</fx:Declarations>

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

chromeColor="#000000"

color="#CCCCCC"

width="517"

height="329">

<mx:ApplicationControlBar width="515"

horizontalAlign="center">

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

fontFamily="verdana"

color="#000000"

x="93" y="41"/>

</mx:ApplicationControlBar>

<mx:Image id="footballImage"

source="@Embed(source='file:/C:/work/bikrant/image/football.png')"

click="{keyframeEffect.end();keyframeEffect.play();}"

x="0" y="77"/>

</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

Advertisements

Ads

Posted on: July 6, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.

Advertisement