forked from: flash on 2009-11-18
// forked from kinoppy's flash on 2009-11-18
package {
import flash.display.*;
import flash.events.Event;
import flash.net.URLRequest;
import caurina.transitions.Tweener;
import caurina.transitions.properties.ColorShortcuts;
import flash.events.MouseEvent;
public class FirstPost extends Sprite {
private var imgArr:Array = ["http://cart05.lolipop.jp/LA08253273/img/product/PR00101605221.jpg"];
private var imgW:Number = 145;
private var imgH:Number = 225;
private var con:Sprite = new Sprite();
private var cur_id:Number = 0;
private var imgLoader:Loader;
public function FirstPost() {
ColorShortcuts.init();
loadImages();
}
private function loadImages():void {
imgLoader = new Loader();
imgLoader.x = -imgW / 2;
imgLoader.y = -imgH / 2;
var path:String = String(imgArr[0]);
var url:URLRequest = new URLRequest(path);
imgLoader.load(url);
con.scaleX = con.scaleY = 0;
con.addChild(imgLoader);
con.x = con.y = 465 / 2;
con.addEventListener(MouseEvent.ROLL_OVER, roImg);
con.addEventListener(MouseEvent.CLICK, clickImg);
addChild(con);
startMotion();
}
private function startMotion():void {
var _scaleRate:Number;
if (cur_id == 0) {
cur_id++;
_scaleRate = stage.stageHeight / imgH;
Tweener.addTween(con, { alpha:1, scaleX:_scaleRate, scaleY:_scaleRate, time:2,
delay:0.5, transition:"easeOutElastic",onComplete:startMotion} );
}else if(cur_id == 1){
cur_id++;
_scaleRate = stage.stageWidth / imgW;
Tweener.addTween(con, { alpha:1, scaleX:_scaleRate, time:1.7, delay:1, transition:"easeOutElastic",onComplete:startMotion} );
}else {
cur_id = 0;
Tweener.addTween(con, { scaleX:0, scaleY:0, rotation:360 * 10, time:2,
delay:2, transition:"easeInOutExpo",onComplete:startMotion} );
}
}
private function roImg(e:MouseEvent):void {
Tweener.addTween(con, { _brightness:2.55, time:0.1, transition:"linear" } );
Tweener.addTween(con, { _brightness:0, time:3, delay:0.1, transition:"easeOutStrong" } );
}
private function clickImg(e:MouseEvent):void {
Tweener.addTween(con, { _brightness:2.55, time:0.1, transition:"linear" } );
Tweener.addTween(con, { _brightness:0, time:3, delay:0.1, transition:"easeOutStrong" } );
}
}
}