LoadGraphic01 on 2010-01-24
♥0 |
Line 31 |
Modified 2010-01-24 00:05:27 |
MIT License
archived:2017-03-20 13:00:52
ActionScript3 source code
/**
* Copyright komatsu ( http://wonderfl.net/user/komatsu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/s471
*/
package {
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.*;
import flash.utils.Timer;
import caurina.transitions.Tweener;
public class LoadGraphic extends Sprite {
private var imgPath:URLRequest;
private var imgLoader:Loader;
public function LoadGraphic() {
imgPath = new URLRequest("http://activefactor.jp/wonderfl/dog.jpg");
imgLoader = new Loader();
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE , imgLoadComp);
imgLoader.load(imgPath);
addChild(imgLoader);
}
private function imgLoadComp(evtObj:Event):void{
imgLoader.alpha = 0;
Tweener.addTween(imgLoader , {alpha:1 , time:5 , transition:"easeOut"});
var moveTimer:Timer = new Timer(1000);
moveTimer.addEventListener(TimerEvent.TIMER , rndMove);
moveTimer.start();
}
private function rndMove(evtObj:TimerEvent):void{
var rndX:int = Math.floor(Math.random()*(stage.stageWidth-imgLoader.width));
var rndY:int = Math.floor(Math.random()*(stage.stageHeight-imgLoader.height));
Tweener.addTween(imgLoader , { x:rndX ,y:rndY, rotation:imgLoader.rotation+45 , time:1 , transition:"easeOut"});
}
}
}