devonair
April 25th, 2007, 10:27 PM
My first little contribution to a brand new forum...
While the Animator class is mainly used for the Copy as Motion to AS3 command, you can of course hand code it as well. Here's a quick color change example I whipped up the other day while playing around..
import fl.motion.Animator;
import fl.motion.MotionEvent;
var redSprite:Sprite = new Sprite();
redSprite.graphics.beginFill(0xFF0000);
redSprite.graphics.drawRect(50, 50, 100,100);
redSprite.graphics.endFill();
addChild(redSprite);
var blue_xml:XML = <Motion duration="10" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="31"></Source>
</source>
<Keyframe index="0">
<tweens>
<SimpleEase ease=".8"/>
</tweens>
</Keyframe>
<Keyframe index="20">
<color>
<Color blueOffset="255" redOffset="-200"/>
</color>
</Keyframe>
</Motion>;
var red_xml:XML = <Motion duration="10" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="31" />
</source>
<Keyframe index="0">
<tweens>
<SimpleEase ease=".8"/>
</tweens>
<color>
<Color blueOffset="255" redOffset="-200" />
</color>
</Keyframe>
<Keyframe index="20">
<color>
<Color blueOffset="0" redOffset="0" />
</color>
</Keyframe>
</Motion>;
var color_animator:Animator;
redSprite.addEventListener(MouseEvent.ROLL_OVER, changeToBlue);
redSprite.addEventListener(MouseEvent.ROLL_OUT, changeToRed);
function changeToBlue(e:MouseEvent):void {
color_animator = new Animator(blue_xml, e.target as Sprite);
color_animator.play();
}
function changeToRed(e:MouseEvent):void {
color_animator = new Animator(red_xml, e.target as Sprite);
color_animator.play();
}
I'm sure other folks will do much cooler stuff, but it's a start..
While the Animator class is mainly used for the Copy as Motion to AS3 command, you can of course hand code it as well. Here's a quick color change example I whipped up the other day while playing around..
import fl.motion.Animator;
import fl.motion.MotionEvent;
var redSprite:Sprite = new Sprite();
redSprite.graphics.beginFill(0xFF0000);
redSprite.graphics.drawRect(50, 50, 100,100);
redSprite.graphics.endFill();
addChild(redSprite);
var blue_xml:XML = <Motion duration="10" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="31"></Source>
</source>
<Keyframe index="0">
<tweens>
<SimpleEase ease=".8"/>
</tweens>
</Keyframe>
<Keyframe index="20">
<color>
<Color blueOffset="255" redOffset="-200"/>
</color>
</Keyframe>
</Motion>;
var red_xml:XML = <Motion duration="10" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="31" />
</source>
<Keyframe index="0">
<tweens>
<SimpleEase ease=".8"/>
</tweens>
<color>
<Color blueOffset="255" redOffset="-200" />
</color>
</Keyframe>
<Keyframe index="20">
<color>
<Color blueOffset="0" redOffset="0" />
</color>
</Keyframe>
</Motion>;
var color_animator:Animator;
redSprite.addEventListener(MouseEvent.ROLL_OVER, changeToBlue);
redSprite.addEventListener(MouseEvent.ROLL_OUT, changeToRed);
function changeToBlue(e:MouseEvent):void {
color_animator = new Animator(blue_xml, e.target as Sprite);
color_animator.play();
}
function changeToRed(e:MouseEvent):void {
color_animator = new Animator(red_xml, e.target as Sprite);
color_animator.play();
}
I'm sure other folks will do much cooler stuff, but it's a start..