Tweensy - repeatType
Tweensyはアニメーションをリピートすることができる。この辺からいよいよTweenerにはない独自機能な香り。
TweensyTimelineオブジェクトのrepeatTypeにリピートの種類を設定することができる。項目は
TweensyTimeline.NONE- デフォルト値。リピートしない。TweensyTimeline.REPLAY- 終点に到達後、すぐに始点に戻って終点へアニメーションする。TweensyTimeline.YOYO- 終点に到達後、delayを挟んで始点へアニメーションする。TweensyTimeline.LOOP- 終点に到達後、すぐに始点へアニメーションし、その後delayする。
- ActionScript
- TestTweensy_6.as
- Source
package {
import com.flashdynamix.motion.Tweensy;
import com.flashdynamix.motion.TweensyTimeline;
import fl.motion.easing.Quadratic;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
[SWF(backgroundColor = 0x000000, width = 600, height = 200, frameRate = 30)]
public class TestTweensy_6 extends Sprite {
private var _boxes:Array;
public function TestTweensy_6() {
initInstances();
startTweensy();
}
private function initInstances():void {
var textFormat:TextFormat = new TextFormat('_等幅', 10, 0xffffff);
var graphics:Graphics = graphics;
graphics.lineStyle(1, 0xffffff, 0.5);
_boxes = [];
var strings:Array = [
'NONE',
'REPLAY',
'YOYO',
'LOOP'
];
var i:int, j:int, y:Number, box:Sprite, textField:TextField;
for (i = 0; i < strings.length; i ++) {
y = 60 + 15 * i;
box = createBox();
box.x = 100;
box.y = y;
_boxes[i] = box;
addChild(box);
graphics.moveTo(100, y);
graphics.lineTo(500, y);
for (j = 0; j < 2; j ++) {
textFormat.align = (j == 0)? TextFormatAlign.RIGHT: TextFormatAlign.LEFT;
textField = new TextField();
textField.defaultTextFormat = textFormat;
textField.text = strings[i];
textField.x = (j == 0)? 10: 510;
textField.y = y - 8;
textField.width = 80;
addChild(textField);
}
}
}
private function createBox():Sprite {
var box:Sprite = new Sprite();
var graphics:Graphics = box.graphics;
graphics.beginFill(0x0099cc);
graphics.drawRect(-5, -5, 10, 10);
graphics.endFill();
return box;
}
private function startTweensy():void{
var repeatTypes:Array = [
TweensyTimeline.NONE,
TweensyTimeline.REPLAY,
TweensyTimeline.YOYO,
TweensyTimeline.LOOP
];
var i:int, box:Sprite, timeline:TweensyTimeline;
for (i = 0; i < _boxes.length; i ++) {
box = _boxes[i];
timeline = Tweensy.to(box, { x: 500 }, 3, Quadratic.easeOut, 1);
timeline.repeatType = repeatTypes[i];
}
}
}
}- package {
- import com.flashdynamix.motion.Tweensy;
- import com.flashdynamix.motion.TweensyTimeline;
- import fl.motion.easing.Quadratic;
- import flash.display.Graphics;
- import flash.display.Sprite;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFormat;
- import flash.text.TextFormatAlign;
- [SWF(backgroundColor = 0x000000, width = 600, height = 200, frameRate = 30)]
- public class TestTweensy_6 extends Sprite {
- private var _boxes:Array;
- public function TestTweensy_6() {
- initInstances();
- startTweensy();
- }
- private function initInstances():void {
- var textFormat:TextFormat = new TextFormat('_等幅', 10, 0xffffff);
- var graphics:Graphics = graphics;
- graphics.lineStyle(1, 0xffffff, 0.5);
- _boxes = [];
- var strings:Array = [
- 'NONE',
- 'REPLAY',
- 'YOYO',
- 'LOOP'
- ];
- var i:int, j:int, y:Number, box:Sprite, textField:TextField;
- for (i = 0; i < strings.length; i ++) {
- y = 60 + 15 * i;
- box = createBox();
- box.x = 100;
- box.y = y;
- _boxes[i] = box;
- addChild(box);
- graphics.moveTo(100, y);
- graphics.lineTo(500, y);
- for (j = 0; j < 2; j ++) {
- textFormat.align = (j == 0)? TextFormatAlign.RIGHT: TextFormatAlign.LEFT;
- textField = new TextField();
- textField.defaultTextFormat = textFormat;
- textField.text = strings[i];
- textField.x = (j == 0)? 10: 510;
- textField.y = y - 8;
- textField.width = 80;
- addChild(textField);
- }
- }
- }
- private function createBox():Sprite {
- var box:Sprite = new Sprite();
- var graphics:Graphics = box.graphics;
- graphics.beginFill(0x0099cc);
- graphics.drawRect(-5, -5, 10, 10);
- graphics.endFill();
- return box;
- }
- private function startTweensy():void{
- var repeatTypes:Array = [
- TweensyTimeline.NONE,
- TweensyTimeline.REPLAY,
- TweensyTimeline.YOYO,
- TweensyTimeline.LOOP
- ];
- var i:int, box:Sprite, timeline:TweensyTimeline;
- for (i = 0; i < _boxes.length; i ++) {
- box = _boxes[i];
- timeline = Tweensy.to(box, { x: 500 }, 3, Quadratic.easeOut, 1);
- timeline.repeatType = repeatTypes[i];
- }
- }
- }
- }
About this entry
You’re currently reading “Tweensy - repeatType,” an entry on jp.ferv.blog
- Published:
- Fri, May 15th, 2009 at 12:28 AM
- Author:
- dsk
- Category:
- Web
- Tags:
- ActionScript 3.0, Tweensy
No comments
Jump to comment form | comments rss | trackback uri