ワンダフルクエスト用
font: http://slime4.hp.infoseek.co.jp/font/font.html
/**
* Copyright alpicola ( http://wonderfl.net/user/alpicola )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/kad55
*/
// font: http://slime4.hp.infoseek.co.jp/font/font.html
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
[SWF(width="465", height="465")]
public class DQ extends Sprite {
public function DQ() {
stage.scaleMode = "noScale";
stage.align = "TL";
Security.loadPolicyFile("http://5ivestar.org/swf/crossdomain.xml");
var loader:Loader = new Loader();
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
context.securityDomain = SecurityDomain.currentDomain;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
loader.load(new URLRequest("http://5ivestar.org/swf/DQFC.swf"), context);
graphics.beginFill(0x000000);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
}
public function loaded(e:Event):void {
var message:DQTextField = new DQTextField(30, 4);
message.text = "*「おお ゆうしゃよ しんでしまうとは なさけない!";
var padding:uint = (stage.stageWidth - message.textWidth) / 2;
message.x = padding
message.y = stage.stageHeight - message.textHeight - padding;
addChild(message);
var command:DQTextField = new DQTextField(10, 3);
command.caption = "コマンド";
command.text = [
"}はなす じゅもん",
" つよさ どうぐ",
" そうび しらべる",
].join("\n");
command.x = command.y = padding;
addChild(command);
}
}
}
import flash.text.*;
class DQTextField extends TextField {
private var _cols:uint = 30;
private var _rows:uint = 3;
private var _text:String = "";
private var _caption:String = "";
private static const DAKUON:String = "がぎぐげござずぜぞぢづでばびべぼガギグゲゴザジズゼゾダヂヅデバビブベボ";
private static const HANDAKUON:String = "ぱぴぷぺぽパピプペポ";
public function DQTextField(cols:uint = 30, rows:uint = 3):void {
autoSize = "left";
embedFonts = true;
multiline = true;
background = true;
backgroundColor = 0x000000;
textColor = 0xFFFFFF;
text
var fmt:TextFormat = new TextFormat();
fmt.font = "dqfc";
fmt.size = 14;
defaultTextFormat = fmt;
_cols = cols;
_rows = rows;
_caption = "";
}
override public function get text():String {
return _text;
}
override public function set text(s:String):void {
_text = s;
super.text = prettify(_text);
}
public function get cols():uint {
return _cols;
}
public function set cols(i:uint):void {
_cols = i;
super.text = prettify(_text);
}
public function get rows():uint {
return _rows;
}
public function set rows(i:uint):void {
_rows = i;
super.text = prettify(_text);
}
public function get caption():String {
return _caption;
}
public function set caption(s:String):void {
_caption = s;
super.text = prettify(_text);
}
private function prettify(s:String):String {
var r:String, c:String;
if (_caption == "" || _cols < 3) {
r = "&" + repeat("#", _cols) + "’\n";
} else {
c = _caption.substr(0, _cols - 2);
var l:uint = (_cols - c.length) / 2;
r = "&" + repeat("#", l - 1) + "=" + c + repeat("#", l + (_cols - c.length) % 2) + "’\n";
}
var lines:Array = s.split("\n");
for (var i:int = 0; i < _rows; i++) {
var line:String = lines.shift() || "";
var buf:Array = ["”", "”"];
if (line.length > _cols) {
lines.unshift(line.substring(_cols));
}
for (var j:int = 0; j < _cols; j++) {
c = line.charAt(j);
if (c == "" || c == " ") c = " ";
if (DAKUON.indexOf(c) != -1) {
buf[0] += "<";
buf[1] += String.fromCharCode(c.charCodeAt(0) - 1);
} else if (HANDAKUON.indexOf(c) != -1) {
buf[0] += ">";
buf[1] += String.fromCharCode(c.charCodeAt(0) - 2);
} else {
buf[0] += " ";
buf[1] += c;
}
}
buf[0] += "$";
buf[1] += "$";
r += buf.join("\n");
r += "\n";
}
r += ")" + repeat("%", _cols) + "(";
return r;
}
private function repeat(s:String, n:int):String {
var r:String = '';
while (n--) r += s;
return r;
}
}