Spark KeyFrames Effect in Flex4
The keyframe defines the value of a property at a specific time during the effect.
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 "
>
0
<s:keyframes>
<s:Keyframe
time=" 250 "
value=" 0 " />
<s:Keyframe
time=" 500 "
value=" 150 " />
1
<s:Keyframe
time=" 750 "
value=" 0 " />
<s:Keyframe
time=" 1000 "
value=" 150 " />
<s:Keyframe
time=" 1250 "
value=" 0 " />
2
<s:Keyframe
time=" 1500 "
value=" 150 " />
<s:Keyframe
time=" 1750 "
value=" 0 " />
<s:Keyframe
time=" 2000 "
value=" 150 " />
3
<s:Keyframe
time=" 2250 "
value=" 0 " />
<s:Keyframe
time=" 2500 "
value=" 150 " />
<s:Keyframe
time=" 2750 "
value=" 0 " />
4
<s:Keyframe
time=" 3000 "
value=" 150 " />
<s:Keyframe
time=" 3250 "
value=" 0 " />
<s:Keyframe
time=" 3500 "
value=" 150 " />
5
<s:Keyframe
time=" 3750 "
value=" 77 " />
</s:keyframes>
</s:MotionPath>
6
</s:motionPaths>
</s:AnimateTransform>
</fx:Declarations>
7
<s:Panel
title=" Spark KeyFrames Effect
Example "
chromeColor="
#000000 "
color="
#CCCCCC "
8
width="
517 "
height="
329 " >
<mx:ApplicationControlBar
width=" 515 "
9
horizontalAlign="
center " >
<s:Label
text=" Click on Image for showing
the effect "
fontFamily="
verdana "
0
color="
#000000 "
x="
93 "
y=" 41 " />
</mx:ApplicationControlBar>
1
<mx:Image
id=" footballImage "
source="
@Embed(source='file:/C:/work/bikrant/image/football.png') "
click="{keyframeEffect.end();keyframeEffect.play();}"
2
x="
0 "
y=" 77 " />
</s:Panel>
</s:Application>
3
Output:
Running Application:
To view this page ensure that Adobe Flash Player version
10.0.0 or greater is installed.
Either scripts and active content are not permitted to run or Adobe Flash Player version
10.0.0 or greater is not installed.
4
Download this code