続きましてFixedVibrationクラスを試してみました。
まずはalphaの値を変化させてみました。
This movie requires Flash Player 9
package {
import flash.display.Sprite;
import hype.extended.behavior.FixedVibration;
public class Hype extends Sprite {
private var rect:Rect;
public function Hype() {
rect = new Rect();
addChild(rect);
rect.x = stage.stageWidth /2;
rect.y = stage.stageHeight /2;
//第1引数:ターゲットオブジェクト
//第2引数:ターゲットプロパティ
//第3引数:バネの係数
//第4引数:イージングの係数
//第5引数:最小値
//第6引数:最大値
//第7引数:相対値か絶対値か
var behavior:FixedVibration = new FixedVibration(rect, "alpha", 0.9, 0.1, 0.0, 1.0, false);
behavior.start();
}
}
}
ゆらゆらと明滅しています!
最小値と最大値の最大範囲はプロパティによって変化します。
続いてscale、rotation、x位置とy位置を変化させてみました。
This movie requires Flash Player 9
package {
import flash.display.Sprite;
import hype.extended.behavior.FixedVibration;
public class Hype extends Sprite {
private var rect:Rect;
public function Hype() {
var rect_array:Array = new Array();
for(var i:int = 1; i < 4; i++){
rect_array[i] = new Rect();
addChild(rect_array[i]);
rect_array[i].x = stage.stageWidth / 4 * i;
rect_array[i].y = stage.stageHeight /2;
}
//scaleを振動
var behavior1:FixedVibration = new FixedVibration(rect_array[1], "scale", 0.9, 0.1, 0.5, 2.0, false);
behavior1.start();
//rotationを振動
var behavior2:FixedVibration = new FixedVibration(rect_array[2], "rotation", 0.9, 0.1, 0, 360, false);
behavior2.start();
//x位置とy位置を振動
var behavior3x:FixedVibration = new FixedVibration(rect_array[3], "x", 0.9, 0.1, -40, 40, true);
var behavior3y:FixedVibration = new FixedVibration(rect_array[3], "y", 0.9, 0.1, -40, 40, true);
behavior3x.start();
behavior3y.start();
}
}
}
面白いですねー。
ではいっそのこと、ぜんぶ一緒にかけてみます。
This movie requires Flash Player 9
package {
import flash.display.Sprite;
import hype.extended.behavior.FixedVibration;
public class Hype extends Sprite {
private var rect:Rect;
public function Hype() {
var rect = new Rect();
addChild(rect);
rect.x = stage.stageWidth /2;
rect.y = stage.stageHeight /2;
//alpha、scale、rotation、x位置とy位置を振動
var behaviorAlpha:FixedVibration = new FixedVibration(rect, "alpha", 0.9, 0.1, 0.0, 1.0, false);
var behaviorScale:FixedVibration = new FixedVibration(rect, "scale", 0.9, 0.1, 0.5, 2.0, false);
var behaviorRotation:FixedVibration = new FixedVibration(rect, "rotation", 0.9, 0.1, 0, 360, false);
var behaviorX:FixedVibration = new FixedVibration(rect, "x", 0.9, 0.1, -40, 40, true);
var behaviorY:FixedVibration = new FixedVibration(rect, "y", 0.9, 0.1, -40, 40, true);
behaviorRotation.start();
behaviorScale.start();
behaviorAlpha.start();
behaviorX.start();
behaviorY.start();
}
}
}
生きてるみたいです!
これらも、ひとつひとつは2行で書けますね。
簡単です。