にじ・・・? forked from: Saqoosha challenge for amateurs
@author OKASUKE*
20日:Wonderfl上だとpackage外でfrocessingがエラーにならないか
確認・・・動くなぁ。。。
CS4だとError #1014: クラス frocessing.display::F5MovieClip2DBmp が見つかりません。
と怒られなくなったが(;ω;)ウゥ・・・変数宣言されてませんエラーがでるorz
21日:いじでもThreadを使ってみる。
22日:mp3(時報の音)がほしい・・・時報の音が。。。 orz
23日: Up予定・・・ヽ(´ー`)ノジカンネェー
もはや、アドリブの力技に・・・
初回コンパイル時57~58の間なぜかバウンドしてくれない。。。なぜ?
wonderflCLOCKとかおもしろそうだなー、5秒ごとに作品と繋ぎ合わせたり。
import org.libspark.thread.utils.SerialExecutor;
/**
* Copyright OKASUKE ( http://wonderfl.net/user/OKASUKE )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mk8K
*/
/*
*@author OKASUKE*
*20日:Wonderfl上だとpackage外でfrocessingがエラーにならないか
*確認・・・動くなぁ。。。
*CS4だとError #1014: クラス frocessing.display::F5MovieClip2DBmp が見つかりません。
*と怒られなくなったが(;ω;)ウゥ・・・変数宣言されてませんエラーがでるorz
*21日:いじでもThreadを使ってみる。
*22日:mp3(時報の音)がほしい・・・時報の音が。。。 orz
*23日: Up予定・・・ヽ(´ー`)ノジカンネェー
*もはや、アドリブの力技に・・・
*初回コンパイル時57~58の間なぜかバウンドしてくれない。。。なぜ?
*wonderflCLOCKとかおもしろそうだなー、5秒ごとに作品と繋ぎ合わせたり。
*/
// forked from checkmate's Saqoosha challenge for amateurs
package {
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.text.TextField;
import org.libspark.thread.Thread;
//import org.libspark.thread.utils.SerialExecutor;
import org.libspark.thread.EnterFrameThreadExecutor;
[SWF(width=465, height=465, backgroundColor=0xffffff, frameRate=120)]
public class GradationTest1 extends Sprite {
//ステージ初期化a
public function GradationTest1() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var text1:TextField = new TextField();
text1.width = 200;
//text1.text = "制作中 23日完成予定でございます。"
//addChild(text1);
Thread.initialize(new EnterFrameThreadExecutor());
new MyThread(this).start();
}
}
}
//////////////////////////////////////////////////////
import org.libspark.thread.Thread;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.core.easing.IEasing;
import org.libspark.betweenas3.easing.Cubic;
import org.libspark.betweenas3.easing.Linear;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.easing.*;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.text.TextFieldAutoSize;
import flash.text.AntiAliasType;
import flash.filters.GlowFilter;
import frocessing.color.ColorLerp;
import frocessing.display.F5MovieClip2D;
import frocessing.display.F5MovieClip2DBmp;
import flash.system.Security;
import flash.media.Sound;
import flash.net.URLRequest;
class Gradation {
private var _colors:Array;
private var _easing:IEasing;
public function Gradation(...args) {
_colors = args.concat();
_easing = Quad.easeIn;
}
public function setEasing(easing:IEasing):void {
_easing = easing;
}
public function getColor(position:Number):uint {
position = (position < 0 ? 0 : position > 1 ? 1 : position) * (_colors.length - 1);
var idx:int = position;
var alpha:Number = _easing.calculate(position - idx, 0, 1, 1);
if (alpha == 0) {
return _colors[idx];
} else {
return ColorLerp.lerp(_colors[idx], _colors[idx + 1], alpha);
}
}
}
//Thread使う。***************************************
class MyThread extends Thread {
public var stage:Stage;
//private var _count:int;
private var _base2:GradationTest1;
private var _count:CountThread;
private var _nijith:NijiThread;
//音 テストちと借ります。a
//private var shutterSndURL:String = "http://www.t-p.jp/flash/FOLEY CAMERA TAKE PICTURE 01.mp3";
//private var shutterSnd:Sound;
public function MyThread(base:GradationTest1):void {
this.stage = base.stage;
_base2 = base;
//音 テストちと借ります。z
//Security.loadPolicyFile("http://www.t-p.jp/crossdomain.xml");
//shutterSnd = new Sound(new URLRequest(shutterSndURL));
}
override protected function run():void {
//trace('MyThread run');
_count = new CountThread(_base2);
_count.start();
_count.join();
next(world);
}
private function world():void {
//shutterSnd.play();
next(run);
}
//private function reset():void {
//next(run);
//}
}
//////////////////////////////////////////////////////////
//カウント実行
class CountThread extends Thread
{
private var _count1:uint = 0;
private var _texttime:TextField = new TextField();
private var _base:GradationTest1;
//private var _base2:Sprite;
public function CountThread(base:GradationTest1):void
{
_texttime.text = ""
_base = base;
Nijiback();
TimeDraw();
//trace("CountThreadコンスト");
}
override protected function run():void
{
// カウントして出力z
if(_texttime.text != "01:59:59") {
sleep(1000);
}
var secondCount:int = _count1 + 5;
if (_count1 >= 6) {
_texttime.text = "02:00:00";
} else {
//57~58の時たまにバウンドしてくれない・・・なぜ?wonderfl
var t2:ITween = BetweenAS3.tween(_texttime, {scaleX:1.7, scaleY:1.7,alpha:1.0}, {scaleX:1.0, scaleY:1.0, alpha:0.1}, 0.4, Bounce.easeOut)
t2.play();
_texttime.text = "01:59:5" + String(_count1 + 5);
}
// 割り込まれていた場合終了
if (checkInterrupted()) {
return;
}
if (++_count1 <= 5) {
next(run);
} else {
//_base.graphics.clear();
_base.removeChild(_texttime as DisplayObject);
next(nijistart);
}
}
private function nijistart():void {
var NijiTh:NijiThread = new NijiThread(_base);
NijiTh.start();
NijiTh.join();
}
private function Nijiback():void {
_base.graphics.clear();
var grad:Gradation = new Gradation(0xED1A3D,0xFFB74C,0xFFFF00,0x00AA00,0x009AD6,0x234794,0xA757A8);
for ( var y:int = 0; y < 465; y++ ) {
_base.graphics.beginFill(grad.getColor(y / 464));
_base.graphics.drawRect(0, y, 465, 1);
_base.graphics.endFill();
}
}
private function TimeDraw():void {
var format:TextFormat = new TextFormat();
format.font = "Impact";
format.size = 48;
format.align = TextFormatAlign.CENTER;
//_texttime = new TextField();
_texttime.x = 85 ;
_texttime.y = 177;
_texttime.alpha = 0.2;
_texttime.text = "01:59:54";
_texttime.selectable = false;
_texttime.type = TextFieldType.DYNAMIC;
_texttime.antiAliasType = AntiAliasType.ADVANCED;
_texttime.autoSize = TextFieldAutoSize.CENTER;
_texttime.textColor = 0xffffff;
_texttime.defaultTextFormat = format;
var glow:GlowFilter = new GlowFilter(0xffffff, 0.8, 8, 8, 4, 2, false, false);
_texttime.filters = [glow];
_base.addChild(_texttime as DisplayObject);
var t1:ITween = BetweenAS3.tween(_texttime, { x: 110 - _texttime.width/2, y: 200 - _texttime.width/2 , alpha:1.0, scaleX:1.7, scaleY:1.7 }, null, 0.5, Bounce.easeOut);
t1.play();
}
}
class NijiThread extends Thread
{
private var _base:GradationTest1;
private var _Niji:Niji;
public function NijiThread(base:GradationTest1):void
{
_base = base;
}
override protected function run():void
{
_Niji = new Niji(_base);
_base.addChild(_Niji);
sleep(5000);
next(stop);
}
private function stop():void
{
_Niji.deleteNiji();
_base.removeChild(_Niji);
_Niji.noLoop();
_Niji = null;
}
}
////////////////////////////////////////////////////////////
class Niji extends F5MovieClip2D
{
private var n:int;
private var Nijitext:TextField = new TextField();
private var _base:GradationTest1;
private var _NijiText:Sprite = new Sprite();
private var _NijiText2:Sprite = new Sprite();
private var _NijiText3:Sprite = new Sprite();
private var _NijiText4:Sprite = new Sprite();
private var _strNijis:Vector.<String> = new Vector.<String>;
public function Niji(base:GradationTest1):void {
_base = base;
setup();
}
//描画プログラムの初期化(ADDED_TO_STAGE)
public function setup():void {
n = 0;
MojiSet();
NijiText();
NijiText4();
NijiText3();
NijiText2();
}
public function draw():void {
_base.graphics.clear();
var r:Number = Math.random() * 0xAA0000;
var g:Number = Math.random() * 0x00BB00;
var b:Number = Math.random() * 0x0000AA;
var grad:Gradation = new Gradation(r, g, b);
for ( var y:int = 0; y < 465; y += 5 ) {
_base.graphics.beginFill(grad.getColor(y / 464));
_base.graphics.drawRect(0, y, 465, 5);
_base.graphics.endFill();
}
_NijiText.y += 5 * 0.96;
_NijiText2.y += 5 * 0.96;
if (_NijiText.y >= 465) {
_NijiText.y = -465;
}
if (_NijiText2.y >= 465) {
_NijiText2.y = -465;
}
_NijiText3.x += 5 * 0.96;
_NijiText4.x += 5 * 0.96;
if (_NijiText3.x >= 465) {
_NijiText3.x = -465;
}
if (_NijiText4.x >= 465) {
_NijiText4.x = -465;
}
}
private function MojiSet():void {
_strNijis = Vector.< String >(["弐時", "2:00", "2時", "2 o'clock", "にじ",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two",
"弐時", "2:00", "2時", "2 o'clock", "two"
]);
}
private function NijiText():void {
/*if (Nijitext.text != "") {
Nijitext.x = 230;
Nijitext.y = 230;
return
}
Nijitext.text = "弐時";
addChild(Nijitext);*/
for (var x:int = 0; x < 465; x += 50) {
for (var y:int = 0; y < 465; y += 50) {
var Nijis:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = "Impact";
format.size = 28;
format.align = TextFormatAlign.CENTER;
Nijis.text = _strNijis[Math.round(Math.random() * 50)];//"2時";
Nijis.selectable = false;
Nijis.type = TextFieldType.DYNAMIC;
Nijis.antiAliasType = AntiAliasType.ADVANCED;
Nijis.autoSize = TextFieldAutoSize.CENTER;
Nijis.x = x;
Nijis.y = y;
Nijis.textColor = 0xFFFFFF;
Nijis.alpha = Math.random() * 0.5;
Nijis.setTextFormat(format);
var glow:GlowFilter = new GlowFilter(0x3366BB, 0.8, 8, 8, 4, 2, false, false);
Nijis.filters = [glow];
_NijiText.addChild(Nijis);
}
}
_base.addChild(_NijiText);
_NijiText.y = 0;
}
//Class化すればよかった・・・アドリブですまぬ。
private function NijiText2():void {
var i:int = 0;
for (var x:int = 0; x < 465; x += 50) {
for (var y:int = 0; y < 465; y += 50) {
var Nijis2:TextField = new TextField();
var format2:TextFormat = new TextFormat();
format2.font = "Impact";
format2.size = 32;
format2.align = TextFormatAlign.CENTER;
Nijis2.text = _strNijis[Math.round(Math.random() * 50)];//"2時"
Nijis2.selectable = false;
Nijis2.type = TextFieldType.DYNAMIC;
Nijis2.antiAliasType = AntiAliasType.ADVANCED;
Nijis2.autoSize = TextFieldAutoSize.CENTER;
Nijis2.x = x;
//Math.random() * 465;
Nijis2.y = y;
// Math.random() * 465;
Nijis2.textColor = 0xFFFFFF;
Nijis2.alpha = Math.random() * 0.6;
Nijis2.setTextFormat(format2);
var glow:GlowFilter = new GlowFilter(0x3366BB, 0.8, 8, 8, 4, 2, false, false);
Nijis2.filters = [glow];
_NijiText2.addChild(Nijis2);
}
}
_base.addChild(_NijiText2);
_NijiText2.y = -465;
}
private function NijiText3():void {
var i:int = 0;
for (var x:int = 0; x < 465; x += 50) {
for (var y:int = 0; y < 465; y += 50) {
var Nijis3:TextField = new TextField();
var format3:TextFormat = new TextFormat();
format3.font = "Impact";
format3.size = 28;
format3.align = TextFormatAlign.CENTER;
Nijis3.text = _strNijis[Math.round(Math.random() * 50)];
Nijis3.selectable = false;
Nijis3.type = TextFieldType.DYNAMIC;
Nijis3.antiAliasType = AntiAliasType.ADVANCED;
Nijis3.autoSize = TextFieldAutoSize.CENTER;
Nijis3.x = x;
//Math.random() * 465;
Nijis3.y = y;
// Math.random() * 465;
Nijis3.textColor = 0xFFFFFF;
Nijis3.alpha = Math.random() * 0.6;
Nijis3.setTextFormat(format3);
var glow:GlowFilter = new GlowFilter(0x3366BB, 0.8, 8, 8, 4, 2, false, false);
Nijis3.filters = [glow];
_NijiText3.addChild(Nijis3);
}
}
_base.addChild(_NijiText3);
_NijiText3.x = 0;
}
private function NijiText4():void {
var i:int = 0;
for (var x:int = 0; x < 465; x += 50) {
for (var y:int = 0; y < 465; y += 50) {
var Nijis4:TextField = new TextField();
var format4:TextFormat = new TextFormat();
format4.font = "Impact";
format4.size = 28;
format4.align = TextFormatAlign.CENTER;
Nijis4.text = _strNijis[Math.round(Math.random() * 50)]; //"2時"//_strnijis.pop();
Nijis4.selectable = false;
Nijis4.type = TextFieldType.DYNAMIC;
Nijis4.antiAliasType = AntiAliasType.ADVANCED;
Nijis4.autoSize = TextFieldAutoSize.CENTER;
Nijis4.x = x;
//Math.random() * 465;
Nijis4.y = y;
// Math.random() * 465;
Nijis4.textColor = 0xFFFFFF;
Nijis4.alpha = Math.random() * 0.5;
Nijis4.setTextFormat(format4);
var glow:GlowFilter = new GlowFilter(0x3366BB, 0.7, 8, 8, 4, 2, false, false);
Nijis4.filters = [glow];
_NijiText4.addChild(Nijis4);
}
}
_base.addChild(_NijiText4);
_NijiText4.x = -465;
}
public function deleteNiji():void {
_base.graphics.clear();
_base.removeChild(_NijiText);
_base.removeChild(_NijiText2);
_base.removeChild(_NijiText3);
_base.removeChild(_NijiText4);
}
//MOUSE_DOWNイベント時に実行a
public function mousePressed():void
{
noLoop();
}
//MOUSE_UPイベント時に実行a
public function mouseReleased():void
{
loop();
}
public function Clear():void {
_base.graphics.clear();
}
}
//テスト
//Wonderflだとエラーはでないか試してみる。
class NijiTEST extends F5MovieClip2D {
public function setup():void
{
//キャンバスのサイズ指定
size( 465, 465 );
//背景の描画
background( 0 );
//色指定
stroke( 255, 0.5 );
}
public function draw():void
{
if ( isMousePressed )
background( 0 );
//直線の描画
line( pmouseX, pmouseY, mouseX, mouseY );
}
}