まずはスープからのんでくれっ!forked from: colin challenge for amateurs
OKASUKE まだ未完成です。間に合うのか・・・残り1日(;ω;)ウッ!
* StartDay 2009/08/12 BetweenAS3を試してみる。
* 2009/08/13 何かの具を追加予定
* 2009/08/14 エフェクトで何か試してみる。
* 2009/08/15 湯気か何かのTEST
* 2009/08/16 ( ゚д゚ )ヤスミクレ 08/17 湯気のつづき、シンプルに
* 2009/08/19 湯気、具など effect重くなるなぁ・・・orz
* 2009/08/20 具を追加 2009/08/21 チャーシュー撮り。
* 2009/08/22 具を追加して、コンパイルが。。。orz
* EndDay 2009/08/23 Up予定
*
* Draw a Tasty Ramen !
*
* You can edit and modify every piece of this code.
* Load more pictures of GU (ingredients of ramen)
* from flickr or draw one by yourself.
* Make it look tasty.
*
/**
* Copyright OKASUKE ( http://wonderfl.net/user/OKASUKE )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/48aW
*/
// forked from checkmate's colin challenge for amateurs
/* OKASUKE まだ未完成です。間に合うのか・・・残り1日(;ω;)ウッ!
* StartDay 2009/08/12 BetweenAS3を試してみる。
* 2009/08/13 何かの具を追加予定
* 2009/08/14 エフェクトで何か試してみる。
* 2009/08/15 湯気か何かのTEST
* 2009/08/16 ( ゚д゚ )ヤスミクレ 08/17 湯気のつづき、シンプルに
* 2009/08/19 湯気、具など effect重くなるなぁ・・・orz
* 2009/08/20 具を追加 2009/08/21 チャーシュー撮り。
* 2009/08/22 具を追加して、コンパイルが。。。orz
* EndDay 2009/08/23 Up予定
*
* Draw a Tasty Ramen !
*
* You can edit and modify every piece of this code.
* Load more pictures of GU (ingredients of ramen)
* from flickr or draw one by yourself.
* Make it look tasty.
*
*/
package{
import flash.display.Sprite;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
//追加
import flash.text.TextField;
import flash.geom.Point;
import flash.geom.ColorTransform;
import flash.filters.DisplacementMapFilter;
import flash.filters.BlurFilter;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.easing.*;
[SWF(width="460", height="460", backgroundColor="0xFFFFFF", frameRate="30")]
public class FlashTest extends Sprite{
private var _loader :Loader;
private var _loaderInfo :LoaderInfo;
private var _loader_GU :Loader;
private var _loaderInfo_GU :LoaderInfo;
//追加
private var _loader_MEN :Loader;
private var _loaderInfo_MEN :LoaderInfo;
private var _loader_MENMA:Loader;
private var _loaderInfo_MENMA :LoaderInfo;
private var _loader_CYASYU :Loader;
private var _loaderInfo_CYASYU :LoaderInfo;
private var _bitmapMen:Bitmap;
public static const BL_LOOP:Number = 10;
private var _TestShape :Shape = new Shape;
private var _TestBitData :BitmapData;
private var _TestBmp1 :Bitmap;
private var _BitmapArray: Array = new Array();
private var sw:int = stage.stageWidth;
private var sh:int = stage.stageHeight;
private var RAMEN_URL :String = "http://farm3.static.flickr.com/2589/3787648401_0b3d62a314_o.png";
private var NARUTO1_URL :String = "http://farm3.static.flickr.com/2466/3787648415_1f857d46cf_o.png";
private var NARUTO2_URL :String = "http://farm4.static.flickr.com/3560/3788456920_5101174e6c_o.png";
private var MENMA_URL :String = "http://farm3.static.flickr.com/2628/3788456906_91e357245f_o.png";
private var MENONLY_URL:String = "http://farm4.static.flickr.com/3427/3810576942_12c1f0106e.jpg";
private var CYASYU_URL:String = "http://farm4.static.flickr.com/3542/3844441719_ee242ea7c2_o.png";
public function FlashTest(){
stage.quality = StageQuality.MEDIUM;
var text1:TextField = new TextField()
text1.x = stage.stageWidth / 2;
text1.y = stage.stageHeight / 2;
text1.text = 'Wait 準備中...';
//addChild(text1);//一旦閉店しないとプラウザが重くなって編集できないす。orz
init();
}
private function init():void{
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
var req:URLRequest = new URLRequest(RAMEN_URL);
_loader = new Loader();
_loader.load(req, new LoaderContext(true));
//_loader.load(new URLRequest(RAMEN_URL));
_loaderInfo=_loader.contentLoaderInfo;
_loaderInfo.addEventListener(Event.COMPLETE,onLoadComplete);
}
private function onLoadComplete(event:Event):void{
_loaderInfo.removeEventListener(Event.COMPLETE,onLoadComplete);
//addChild(_loader);
/* var sw:int = stage.stageWidth;
var sh:int = stage.stageHeight;
読み込んだ画像を一旦リサイズ
var source:Bitmap = _loader as Bitmap;
var resizeData:BitmapData = new BitmapData(sw, sh);
_loader.width = sw;
_loader.height = sh;
addChild(_loader); //kokodedame
resizeData.draw( _loader );
_bitmapEffect = new Bitmap(resizeData);
//????なぜ表示されない。。。? CS4datoOK!
//addChild(_bitmapEffect); */
load_MENONLY();
load_GU();
load_MENMA();
load_CYASYU();
}
//麺ONLYアップロード
private function load_MENONLY():void {
//_loader_MEN = new Loader();
//_loader_MEN.load(new URLRequest(MENONLY_URL));
var req:URLRequest = new URLRequest(MENONLY_URL);
_loader_MEN = new Loader();
_loader_MEN.load(req, new LoaderContext(true));
_loaderInfo_MEN = _loader_MEN.contentLoaderInfo;
_loaderInfo_MEN.addEventListener(Event.COMPLETE, onLoadComplete_MEN);
}
private function onLoadComplete_MEN(event:Event):void {
_loaderInfo_MEN.removeEventListener(Event.COMPLETE, onLoadComplete_MEN);
TestperlinNoise()
}
//具(なると)
private function load_GU():void{
_loader_GU=new Loader();
_loader_GU.load(new URLRequest(NARUTO1_URL));
_loaderInfo_GU=_loader_GU.contentLoaderInfo;
_loaderInfo_GU.addEventListener(Event.COMPLETE,onLoadComplete_GU);
}
private function onLoadComplete_GU(event:Event):void{
_loaderInfo_GU.removeEventListener(Event.COMPLETE,onLoadComplete_GU);
}
//具(メンマ)
private function load_MENMA():void {
_loader_MENMA = new Loader();
_loader_MENMA.load(new URLRequest(MENMA_URL));
_loaderInfo_MENMA = _loader_MENMA.contentLoaderInfo;
_loaderInfo.addEventListener(Event.COMPLETE, onLoadComplete_MENMA);
}
private function onLoadComplete_MENMA(event:Event):void {
_loaderInfo_MENMA.removeEventListener(Event.COMPLETE, onLoadComplete_MENMA);
}
//具(のり)
private function drawShape(i:Number):void {
/* //TestShape
_TestShape.graphics.beginFill(0x000000, 1.0);
_TestShape.graphics.lineStyle(1);
_TestShape.graphics.lineTo(0, 0);
_TestShape.graphics.lineTo(50, 0);
_TestShape.graphics.lineTo(50, 100);
_TestShape.graphics.lineTo(0, 100);
_TestShape.graphics.lineTo(0, 0);
_TestShape.graphics.endFill();
_TestShape.x = stage.stageWidth / 2;
_TestShape.y = stage.stageHeight / 2;
addChild(_TestShape);
*/
//TestBitmap
_TestBitData = new BitmapData(55, 110, false, 0x000000);
_TestBmp1 = new Bitmap(_TestBitData);
_TestBmp1.x = 100 + (Math.random() * (i * 10));
_TestBmp1.y = 50 + (Math.random() * (i * 10));
//addChild(_TestBmp1);
_BitmapArray.push(_TestBmp1);
addChild(_BitmapArray[i]);
BTween(i);
}
//具(チャーシュ)loader
private function load_CYASYU():void {
var req:URLRequest = new URLRequest(CYASYU_URL);
_loader_CYASYU = new Loader();
_loader_CYASYU.load(req, new LoaderContext(true));
_loaderInfo_CYASYU = _loader_CYASYU.contentLoaderInfo;
_loaderInfo_CYASYU.addEventListener(Event.COMPLETE, onLoadComplete_CYASYU);
}
private function onLoadComplete_CYASYU(event:Event):void {
_loaderInfo_CYASYU.removeEventListener(Event.COMPLETE, onLoadComplete_CYASYU);
}
//具(海苔) BetweenAS3で配置 //beinteractiveさんのチュートリアル参考
private function BTween(i:Number):void {
//var valueX:Number = i * 10;
//var valueY:Number = i * 55;
var rotationR:Number = i;
_BitmapArray[i].alpha = 0.2
var t1:ITween = BetweenAS3.tween(_BitmapArray[i], {x:150 , y:200, alpha:0.6, scaleX:2.0, scaleY:2.0, rotation:-70 + rotationR}, null, 0.8, Bounce.easeOut);
//BetweenAS3.removeFromParent(_BitmapArray[i]);
var n:Number = i+12;
var rad:Number = (n * 20) * Math.PI / 180;
var valueX2:Number = (Math.sin(rad) * 200) + stage.stageWidth / 2 - _BitmapArray[i].width / 2;
var valueY2:Number = (Math.cos(rad) * 200) + stage.stageHeight / 2 - _BitmapArray[i].height / 2;
//_BitmapArray[i].x = valueX + _BitmapArray[i].width/2;
//_BitmapArray[i].y = valueY + _BitmapArray[i].height/2;
//ステージの中心との距離
var Cx:Number = stage.stageWidth / 2 - (valueX2);
var Cy:Number = stage.stageHeight / 2 - (valueY2);
var rota:Number = Math.atan2(Cy, Cx)*180/Math.PI;
var t2:ITween = BetweenAS3.tween(_BitmapArray[i], {x: valueX2 + _BitmapArray[i].width/2, y:valueY2 + _BitmapArray[i].height/2, alpha:1.0, scaleX:1.0, scaleY:1.0, rotation:Math.atan2(Cy, Cx)*180/Math.PI}, null, 2.0, Bounce.easeOut);
BetweenAS3.serial(t1, t2).play();
//BetweenAS3.scale(t1, 0.7).play();
//BetweenAS3.scale(t2, 0.5).play(); //こうじゃないんだ。。
}
//具トゥイーン(narutoだってばよー!) clockmakerさんのを参考に。
private function NarutoTween():void {
var baseTween:ITween;
var sec:Number = 2 * Math.random() + 3;
addChild(_loader_GU);
addChild(_loader_MENMA).scaleX = 0.3;
addChild(_loader_MENMA).scaleY = 0.3;
//配列みたいなもの
baseTween = BetweenAS3.parallel(
BetweenAS3.tween(addChild(_loader_GU), { x:260, y:200}, {scaleX:3, scaleY:3 }, 7, Bounce.easeOut),
BetweenAS3.tween(addChild(_loader_MENMA), { x:150, y:200 }, {scaleX:1, scaleY:1 }, 6, Bounce.easeOut)
);
//切り取ってとりだす
var tw1:ITween = BetweenAS3.slice(baseTween, 0.0, 0.4, true); // 0%から??%までを切り出し
var tw2:ITween = BetweenAS3.slice(baseTween, 0.4, 1.0, true); // ??%から100%までを切り出し
tw1 = BetweenAS3.scale(tw1, 0.4); //??倍
tw2 = BetweenAS3.scale(tw2, 0.5); // ??倍
var totalTween:ITween = BetweenAS3.serial(tw1, tw2);
// 再生
totalTween.play();
totalTween.stopOnComplete = true; // ループ設定
}
//cyasyu タイムリマップの方が自然な感じになる?
private function CyasyuTween():void {
//addChild(_loader_CYASYU).x = 50;
//addChild(_loader_CYASYU).y = 100;
addChild(_loader_CYASYU).scaleX = 3.0;
addChild(_loader_CYASYU).scaleY = 3.0;
//addChild(_loader_CYASYU).rotation = -30;
var t1:ITween = BetweenAS3.tween(addChild(_loader_CYASYU), {x:50 , y:150, scaleX:1.0, scaleY:1.0, rotation:-30}, null, 1.0, Bounce.easeOut);
t1.play();
t1.stop();
t1.gotoAndPlay(3.0);
t1.stop();
t1.gotoAndPlay(2.0);
}
//TEST perlinNoise
private var _Testperlinbit:BitmapData;
private var _seed:Number=Math.floor(Math.random() * 0xFFFF);
private var _offset:Array=[new Point(0, 0), new Point(0, 0),];
private var _bitmapEffect:Bitmap;
//なにかエフェクトお試しテスト中
private function TestperlinNoise():void {
/*これじゃだめっぽい...CS4だとこれでも表示OK(泣)
var bitmapD:BitmapData = Bitmap(_loader.centetn).bitmapData; // as Bitmap;
_bitmapEffect = new Bitmap(bitmapD);
addChild(_bitmapEffect);
*/
//この方法でないとだめなのか...?? //一応、リサイズ
var RebitmapData:BitmapData = new BitmapData(sw, sh);
_loader_MEN.width = sw;
_loader_MEN.height = sh;
RebitmapData.draw(_loader_MEN);
_bitmapEffect = new Bitmap(RebitmapData);
_bitmapEffect.x = sw / 2 - _bitmapEffect.width / 2;
_bitmapEffect.y = sh / 2 - _bitmapEffect.height / 2;
addChild(_loader);
drawCircle();
_bitmapEffect.mask = _circle;
_bitmapEffect.bitmapData.colorTransform(_bitmapEffect.bitmapData.rect, new ColorTransform(1.0, 1.20, 1.0));
addChild(_bitmapEffect);
//
//具(たまご)
TamagoInit();
//具(のり)
for (var i:uint = 0; i < BL_LOOP; i++) {
drawShape(i)
}
//addChild(_loader_GU);
NarutoTween();
CyasyuTween();
_Testperlinbit = new BitmapData(480, 480, false, 0xFFFFFF);
//湯気を出す...
YugeInit();
//EnterFrame
addEventListener(Event.ENTER_FRAME, EffectLoop);
}
//エフェクトループ (鮭とプログラムさんを参考)
//http://sakeprog.cocolog-nifty.com/sake/2008/06/post_90e6.html
private function EffectLoop(e:Event):void {
_Testperlinbit.perlinNoise(_Testperlinbit.width / 2, _Testperlinbit.height / 2, 2,
_seed, false, true, 1, false, _offset);
var dmf:DisplacementMapFilter=new DisplacementMapFilter(_Testperlinbit, new Point(sw/2 - _Testperlinbit.width/2, sh/2 - _Testperlinbit.height / 2), 1, 1, 30, 30);
_bitmapEffect.filters=[dmf];
_offset[0].x += 5;
_offset[1].y += 5;
for (var i:int = 0; i < _particleNum; i++) {
if(_yugeparticles[i].width <= 300) {
_yugeparticles[i].width += 0.96;
_yugeparticles[i].height += 0.96;
if(_yugeparticles[i].alpha >= 0.2)
_yugeparticles[i].alpha -= 0.01;
}
}
}
//円作成
private var _circle:Shape = new Shape();
private function drawCircle():void {
_circle.graphics.beginFill(0x00FFFF, 0.0);
_circle.graphics.drawCircle(0, 0, 177);
_circle.graphics.endFill();
_circle.x=stage.stageWidth/2;
_circle.y=stage.stageHeight/2;
addChild(_circle);
}
//Yuge
private var _yugeparticles:Vector.<Sprite>;
private var prtBlurFilter:BlurFilter;
private var _particleNum:Number = 50;//いくつにするか
private function YugeInit():void {
_yugeparticles = new Vector.<Sprite> ;
for (var i:int = 0; i < _particleNum; i++) {
var particle:Sprite = new Sprite();
particle.graphics.beginFill(0xFFFFFF, 0.3);
particle.graphics.drawCircle(0, 0, 40);
particle.graphics.endFill();
particle.x = Math.random() * 240 + stage.stageWidth/2 - 150;
particle.y = Math.random() * 240 + stage.stageHeight/2 - 150;
var filters_array:Array = new Array();
prtBlurFilter = new BlurFilter(4, 4, 1);
filters_array.push(prtBlurFilter);
particle.filters = filters_array;
addChild(particle);
_yugeparticles.push(particle);
}
}
//具(たまご)追加
//************************************************
private var _tamago:Sprite = new Sprite();
private function TamagoInit():void {
_tamago.graphics.lineStyle(1, 0x000000);
_tamago.graphics.beginFill(0xFFFFFF, 1);
_tamago.graphics.drawEllipse(30, 30, 115, 80);
_tamago.graphics.endFill();
_tamago.rotation = 27; //卵回転、黄身との微調整
_tamago.x= (stage.stageWidth / 2 - _tamago.width / 2) ;
_tamago.y = (stage.stageHeight / 2 - _tamago.height / 2) + 40;
var filters_array:Array = new Array();
var tamagoBlurFilter:BlurFilter = new BlurFilter(6, 6, 1);
filters_array.push(tamagoBlurFilter);
_tamago.filters = filters_array;
addChild(_tamago);
KimiInit();
}
private var _kimi:Sprite = new Sprite();
private function KimiInit():void {
_kimi.graphics.lineStyle(1, 0x000000);
_kimi.graphics.beginFill(0xffdd22, 1.5);
_kimi.graphics.drawEllipse(30, 30, 80, 60);
_kimi.graphics.endFill();
_kimi.rotation = 30;
_kimi.x= (stage.stageWidth/2 - _kimi.width / 2) ;
_kimi.y = (stage.stageHeight / 2 - _kimi.height / 2) + 40;
var filters_array:Array = new Array();
var kimiBlurFilter:BlurFilter = new BlurFilter(4, 2, 1);
filters_array.push(kimiBlurFilter);
_kimi.filters = filters_array;
addChild(_kimi);
}
}
}