Created
October 8, 2009 05:09
-
-
Save hisasann/204756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.*; | |
import flash.events.*; | |
import flash.net.*; | |
import flash.utils.Timer; | |
import flash.events.TimerEvent; | |
public class Main extends Sprite { | |
public function Main() { | |
stage.scaleMode = "noScale"; | |
renderBaseLayer(); | |
// HTMLレンダリングで動作がチラつくのを防ぐためdelayをかける | |
var delay:uint = 2000; | |
var repeat:uint = 1; | |
var timer:Timer = new Timer(delay, repeat); | |
timer.addEventListener("timer", renderOtherLayer); | |
timer.start(); | |
} | |
private function renderBaseLayer():void { | |
new BaseLayer(this); | |
} | |
private function renderOtherLayer(event:TimerEvent):void { | |
new LegLayer(this); | |
new flowerLayer(this); | |
} | |
} | |
} | |
class Constants { | |
public static const URL:String = "http://lab.hisasann.com/NoTechnoNoLife/"; | |
} | |
import flash.display.*; | |
import flash.events.*; | |
import a24.external.tweener.MosaicShortcuts; | |
class BaseLayer extends Sprite { | |
private var _sprite:Sprite; | |
private var _stage:Stage; | |
private var _mc:MovieClip; | |
public function BaseLayer(sprite:Sprite) { | |
this._sprite = sprite; | |
this._stage = sprite.stage; | |
MosaicShortcuts.init(); | |
init(); | |
} | |
private function init():void { | |
var loader:Loader = new Loader(); | |
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); | |
loader.load(new URLRequest(Constants.URL + "image/base.png")); | |
var mc:MovieClip = new MovieClip(); | |
mc.addChild(loader); | |
this._mc = mc; | |
addChild(mc); | |
this._stage.addChild(this); | |
} | |
private function completeHandler(e:Event):void { | |
var _this:MovieClip = this._mc; | |
Tweener.addTween(_this, { | |
_mosaic : 20, | |
time : 1.5, | |
transition : "easeInOutQuad", | |
delay: 2, | |
onComplete: function () { | |
Tweener.addTween(_this, { | |
_mosaic : 0 | |
,time : 1.5 | |
,transition : "easeInOutQuad" | |
}) | |
} | |
}); | |
} | |
} | |
import flash.display.*; | |
import flash.events.*; | |
class LegLayer extends Sprite { | |
private var _sprite:Sprite; | |
private var _stage:Stage; | |
private var images:Array = new Array(); | |
private var rightImageX = 1200; | |
private var leftImageX = -500; | |
public function LegLayer(sprite:Sprite) { | |
this._sprite = sprite; | |
this._stage = sprite.stage; | |
init(); | |
} | |
private function init():void { | |
var position:Object; | |
// right images | |
// image1 | |
var image1:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image1.png"); | |
position = Utis.getStageRandom(this._stage); | |
image1.x = rightImageX; image1.y = position.y; | |
images.push(image1); | |
new ImageAnimator(image1, {x:720, y:0, transition:"easeInOutBack", time:1, delay: 0.1, | |
onComplete: function () { | |
} | |
}).animate(); | |
// image2 | |
var image2:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image2.png"); | |
position = Utis.getStageRandom(this._stage); | |
image2.x = rightImageX; image2.y = position.y; | |
images.push(image2); | |
new ImageAnimator(image2, {x:800, y:0, transition:"easeInOutBack", time:1.5, delay: 0.2, | |
onComplete: function () { | |
} | |
}).animate(); | |
// image3 | |
var image3:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image3.png"); | |
position = Utis.getStageRandom(this._stage); | |
image3.x = rightImageX; image3.y = position.y; | |
images.push(image3); | |
new ImageAnimator(image3, {x:720, y:0, transition:"easeInOutBack", time:2, delay: 0.3, | |
onComplete: function () { | |
} | |
}).animate(); | |
// image4 | |
var image4:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image4.png"); | |
position = Utis.getStageRandom(this._stage); | |
image4.x = rightImageX; image4.y = position.y; | |
images.push(image4); | |
new ImageAnimator(image4, {x:720, y:0, transition:"easeInOutBack", time:2.5, delay: 0.4, | |
onComplete: function () { | |
} | |
}).animate(); | |
// left images | |
// image5 | |
var image5:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image5.png"); | |
position = Utis.getStageRandom(this._stage); | |
image5.x = leftImageX; image5.y = position.y; | |
images.push(image5); | |
new ImageAnimator(image5, {x:0, y:20, transition:"easeInOutBack", time:1, delay: 0.4, | |
onComplete: function () { | |
} | |
}).animate(); | |
// image6 | |
var image6:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image6.png"); | |
position = Utis.getStageRandom(this._stage); | |
image6.x = leftImageX; image6.y = position.y; | |
images.push(image6); | |
new ImageAnimator(image6, {x:-20, y:-25, transition:"easeInOutBack", time:1.5, delay: 0.3, | |
onComplete: function () { | |
} | |
}).animate(); | |
// image7 | |
var image7:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image7.png"); | |
position = Utis.getStageRandom(this._stage); | |
image7.x = leftImageX; image7.y = position.y; | |
images.push(image7); | |
new ImageAnimator(image7, {x:0, y:0, transition:"easeInOutBack", time:2, delay: 0.2, | |
onComplete: function () { | |
} | |
}).animate(); | |
// image8 | |
var image8:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/image8.png"); | |
position = Utis.getStageRandom(this._stage); | |
image8.x = leftImageX; image8.y = position.y; | |
images.push(image8); | |
new ImageAnimator(image8, {x:0, y:0, transition:"easeInOutBack", time:2.5, delay: 0.1, | |
onComplete: function () { | |
} | |
}).animate(); | |
this._stage.addChild(this); | |
//addEventListener(Event.ENTER_FRAME, onEnterFrameHandler, false, 0, true); | |
} | |
private function onEnterFrameHandler(event:Event):void { | |
update(); | |
} | |
private function update():void { | |
} | |
} | |
import flash.display.*; | |
import flash.events.*; | |
import flash.external.ExternalInterface; | |
import flash.system.*; | |
class flowerLayer extends Sprite { | |
private var _sprite:Sprite; | |
private var _stage:Stage; | |
public function flowerLayer(sprite:Sprite) { | |
this._sprite = sprite; | |
this._stage = sprite.stage; | |
init(); | |
} | |
private function init():void { | |
buttonMode = true; // 指アイコン | |
var base:Sprite = new ImageLoader().showImage(this, Constants.URL + "image/flower.png"); | |
base.x = 10; | |
base.y = -200; | |
new ImageAnimator(base, {delay:1.5, x:10, y:0, transition:"easeInOutCirc", time:1.5, | |
onComplete: function () { | |
} | |
}).animate(); | |
this._stage.addChild(this); | |
addEventListener(MouseEvent.CLICK, onClickHandler); | |
} | |
private function onClickHandler(event:Event):void { | |
// リンク機能 | |
var url:String = "http://rastaman.blog39.fc2.com/"; | |
var ur:URLRequest = new URLRequest(url); | |
navigateToURL( ur,"_self"); | |
} | |
} | |
/* 画像アニメーター */ | |
import flash.display.*; | |
import caurina.transitions.*; | |
class ImageAnimator extends Sprite { | |
private var image:Sprite; | |
private var hash:Object; | |
public function ImageAnimator(sprite:Sprite, obj:Object) { | |
this.image = sprite; | |
this.hash = obj; | |
} | |
public function animate() { | |
Tweener.addTween(this.image, this.hash); | |
} | |
} | |
/* 画像ローダー */ | |
import flash.display.*; | |
import flash.net.*; | |
class ImageLoader extends Sprite { | |
var _fn:Function; | |
public function showImage(obj:Sprite, url:String, fn:Function = null):Sprite { | |
var urImage:URLRequest = new URLRequest(url); | |
var img:Loader = new Loader(); | |
if (fn != null) { | |
this._fn = fn; | |
img.contentLoaderInfo.addEventListener(Event.COMPLETE, fn); | |
} | |
img.load(urImage); | |
addChild(img); | |
obj.addChild(this); | |
return this; | |
} | |
} | |
/* ステージランダム座標 */ | |
import flash.display.*; | |
class Utis { | |
public static function getStageRandom(stage:Stage):Object { | |
var obj:Object = new Object(); | |
obj.x = stage.stageWidth * 2 * Math.random(); | |
obj.y = stage.stageHeight * 2 * Math.random(); | |
return obj; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment