開閉
package {
import flash.display.*;
import flash.events.*;
import jp.progression.commands.*;
public class OpenClose extends Sprite{
public function OpenClose():void{
var gate:Sprite = new Sprite();
drawGate(gate);
this.addChild(gate);
var h1:Sprite = new Sprite();
drawLine(h1, 0, 0, 160, 0);
h1.x = 140;
h1.y = 230;
gate.addChild(h1);
var h2:Sprite = new Sprite();
drawLine(h2, 0, 0, 180, 0);
h2.x = 130;
h2.y = 300;
gate.addChild(h2);
var v1:Sprite = new Sprite();
drawLine(v1, 50, 0, 50, 70);
drawLine(v1, 50, 70, 0, 150);
v1.x = 140;
v1.y = 230;
gate.addChild(v1);
var v2:Sprite = new Sprite();
drawLine(v2, 0, 0, 0, 150);
v2.x = 250;
v2.y = 230;
gate.addChild(v2);
var slist:SerialList = new SerialList();
slist.addCommand(
[
tw(h1, {y: h1.y + 35}),
tw(h2, {y: h2.y - 35}),
tw(v1, {x: v1.x + 30}),
tw(v2, {x: v2.x - 30})
],
[
tw(h1, {y: h1.y}),
tw(h2, {y: h2.y}),
tw(v1, {x: v1.x}),
tw(v2, {x: v2.x})
]
);
slist.execute();
}
private function tw(target:Sprite, p:Object):DoTweener{
p.time = 2;
p.transition = 'easeInOutExpo';
return new DoTweener(target, p);
}
private function drawGate(s:Sprite):Sprite{
s.graphics.lineStyle(30, 0x303030, 1, false, LineScaleMode.NORMAL, CapsStyle.ROUND);
// left
s.graphics.moveTo(50, 400);
s.graphics.lineTo(50, 50);
s.graphics.lineTo(200, 50);
s.graphics.lineTo(200, 170);
s.graphics.lineTo(50, 170);
s.graphics.moveTo(50, 110);
s.graphics.lineTo(200, 110);
// right
s.graphics.moveTo(420, 400);
s.graphics.lineTo(420, 50);
s.graphics.lineTo(270, 50);
s.graphics.lineTo(270, 170);
s.graphics.lineTo(420, 170);
s.graphics.moveTo(420, 110);
s.graphics.lineTo(270, 110);
return s;
}
private function drawLine(s:Sprite, x1:Number, y1:Number, x2:Number, y2:Number):Sprite{
s.graphics.lineStyle(30, 0x303030, 1, false, LineScaleMode.NORMAL, CapsStyle.ROUND);
s.graphics.moveTo(15 + x1, 15 + y1);
s.graphics.lineTo(15 + x2, 15 + y2);
return s;
}
}
}