forked from: #1 SingleAsyncImgLoader WonderflBook Interactive3
画像をどうにかしたい
/**
* Copyright otherone ( http://wonderfl.net/user/otherone )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/j2ew
*/
package {
import flash.display.Sprite;
import flash.events.*;
//[SWF( width="465", height="465", backgroundColor="0x000000", frameRate="30" )];
public class WonderflBook extends Sprite {
private var _box:ImgBox;
public function WonderflBook() {
init();
}
public function init():void {
_box = new ImgBox();
_box.x = 50+10;//stage.stageHeight / 2;
_box.y = 50+10;//stage.stageWidth / 2;
addChild( _box );
}
}
}
import flash.display.*;
import flash.events.*;
import caurina.transitions.Tweener;
import flash.net.URLRequest;
class ImgBox extends Sprite {
private var _loader:Loader;
private var _bgRect:Sprite;
private const IMG_SIZE:Number = 100;
private const HALF_SIZE:Number = IMG_SIZE / 2;
//private var HALF_SIZE:Number;
public function ImgBox() {
_loader = new Loader();
_loader.alpha = 0;
addChild( _loader );
this.scaleX = 0.01;
this.scaleY = 0.01;
load();
}
private function load():void {
_loader.contentLoaderInfo.addEventListener( ProgressEvent.PROGRESS, loading );
_loader.contentLoaderInfo.addEventListener( Event.COMPLETE, complete);
_loader.load( new URLRequest( "http://works.mztm.jp/moriya/nekome/kaeru.jpg" ));
}
private function loading( e:ProgressEvent ):void {
var percent:Number = e.bytesLoaded / e.bytesTotal;
}
private function complete( e:Event ):void {
showImg();
}
private function showImg():void {
_loader.x = -HALF_SIZE;
_loader.y = -HALF_SIZE;
Tweener.addTween( this, { scaleX:1, scaleY:1, time:30, useFrames:true, transition:"easeOutElastic" });
Tweener.addTween( _loader, { alpha:1, time:20, useFrames:true, transition:"easeOutExpo" });
}
}