MessageBox
forked from flash on 2010-4-13 (diff: 134)
ActionScript3 source code
/**
* Copyright hacker_johiroshi ( http://wonderfl.net/user/hacker_johiroshi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8Gmz
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.display.Graphics;
public class MessageBox extends Sprite {
private var tf:TextField = new TextField();
private var tfm:TextFormat = new TextFormat;
private var count:int = 0;
public function MessageBox() {
//テキストの設定
var TextDetail = new TextDetail(tf);
addChild(TextDetail);
//テキストボックスの生成
var createTextField = new createTextField(tf, 20, 20, 425, 300);
addChild(createTextField);
//テキストのデフォルト値を設定
//tf.defaultTextFormat = new TextFormat("", 20, 0x0, true);
//TextFormatの生成
tfm.color = 0x000000;
tfm.size = 20;
tfm.italic = true;
tf.appendText("\nIntroduction2");
tf.setTextFormat(tfm);
addChild(tf);
//Bottonの生成
var up:Next = new Next(0x0);
var over:Next = new Next(0xFF4500);
var button:SimpleButton = new SimpleButton(up, over, over, over);
button.x = 350;
button.y = 350;
button.addEventListener(MouseEvent.CLICK, onMouseClick);
addChild(button);
}
//マウスプッシュに依る先送り。Message0.
private function onMouseClick(event:MouseEvent):void
{
if(count==5)
{
RMBox();
removeChild(MessageBox.button);
Next.RNext();
}
var ms0:Array = ["学生も最後か。", "思えば短かったかもしれない。", "学生らしいのは高校生までか。", "これからは半社会人として生きていかなければならないと思うと気が重い。\n\nどうしよう。", "始まる…", "確認array5", "array6"];
tf.text = "\n僕:" + (ms0[count++]);
tf.setTextFormat(tfm);
}
private function RMBox():void
{
removeChild(tf);
tf = null;
tfm = null;
}
}
}
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Graphics;
class Next extends Sprite
{
public function Next(color:int)
{
//”Next”枠の生成
graphics.lineStyle(2.0, color);
graphics.beginFill(0xFFFFFF);
graphics.drawRect(0, 0, 100, 50);
graphics.endFill();
//"Next"のフォーマットの指定
var tf1:TextField = new TextField();
tf1.defaultTextFormat = new TextFormat("_typeWriter", 20, color, true);
tf1.text = "Next";
tf1.autoSize = "left";
tf1.width = 400;
tf1.height = 400;
tf1.x = (this.width - tf1.width) / 2;
tf1.y = (this.height - tf1.height) / 2;
tf1.selectable = false;
addChild(tf1);
}
public static function RNext():void
{
var canvas:Sprite = new Sprite();
var g:Graphics = canvas.graphics;
g.clear();
}
}
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
class TextDetail extends Sprite
{
private var tf:TextField = new TextField();
//テキストの詳細を記入
public function TextDetail(tf:TextField)
{
//TextBoxの生成
//var tf:TextField = new TextField();
tf.text = "Introduction1";
tf.x = 30;
tf.y = 30;
tf.width = 390;
tf.height = 270;
tf.multiline = true; //複数行
tf.wordWrap = true; //テキストの折り返し
//tf.autoSize = "left";
//addChild(tf);
}
}
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
class createTextField extends Sprite
{
public function createTextField(result:TextField, x:Number, y:Number, width:Number, height:Number)
{
result.x = x;
result.y = y;
result.width = width;
result.height = height;
result.border = true;
result.background = true;
addChild(result);
}
}
