forked from: Colorflow
1年半以上前に勉強のためにつくったものをwonderflで
動くように整理し直し。
冗長すぎの、動けば文句内だろ系コードで汚すぎて笑えた。
今回書き直したら、本体部分は行数が半分くらいになったw
変なところは残っている(っていうか根幹から変)けど、
これ以上やると切りがなくなるので終了。
/**
* Copyright Maxfrank ( http://wonderfl.net/user/Maxfrank )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/187J
*/
// forked from umhr's Colorflow
/*
1年半以上前に勉強のためにつくったものをwonderflで
動くように整理し直し。
冗長すぎの、動けば文句内だろ系コードで汚すぎて笑えた。
今回書き直したら、本体部分は行数が半分くらいになったw
変なところは残っている(っていうか根幹から変)けど、
これ以上やると切りがなくなるので終了。
*/
package
{
/**
* ...
* @author umhr
*/
import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.utils.setInterval;
import flash.utils.clearInterval;
import flash.events.MouseEvent;
import flash.events.Event;
public class Colorflow extends Sprite
{
private var ns:NewSlider = new NewSlider();
private var poz:uint = new Number(21);
function Colorflow() {
//プロパティ類
var origin_array:Array = [];
var i:int;
var poz_array:Array = new Array(-480,-30,0,0,0,0);
var sprits:Array = new Array();
var colors_array:Array = new Array(0x00d3ff,0x008eff,0x0043ff,0x0400ff,0x4e00ff,0x9800ff,0xe200ff,0xff00cf,0xff008a,0xff003e,0xfc0000,0xff4900,0xff9300,0xffe000,0xdfff00,0x9dff00,0x64ff00,0x25ff00,0x00ff20,0x00ff7f,0x00ffd5);
var colors2_array:Array = new Array(0xb2f2ff,0xb2ddff,0xb2c6ff,0xb3b2ff,0xcab2ff,0xe0b2ff,0xf6b2ff,0xffb2f1,0xffb2dc,0xffb2c5,0xfeb2b2,0xffc8b2,0xffdeb2,0xfff6b2,0xf5ffb2,0xe1ffb2,0xd0ffb2,0xbdffb2,0xb2ffbc,0xb2ffd8,0xb2fff2);
var animecount_num:uint = new uint(1);
var anime_array:Array = new Array(-480,-30,0,0,0,0);
var animestep_num:uint = new uint(60);
var pt_array:Array = new Array(1);
var maisu:uint = new Number(21);
var pozx_array:Array = new Array(-274,-244,-214,-184,-154,-124,-94,-64,-34,-4,26,56,86,116,146,176,206,236,274,320,480,640,686,722,752,782,812,842,872,902,932,962,992,1022,1052,1082,1112,1142,1172,1202,1232);
var pozy_array:Array = new Array(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,3, 3.5, 4, 4.5, 5, 5.5, 6, 250, 6, 5.5, 5, 4.5, 4, 3.5, 3,1.2,1.1,1.0,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1,0.0);
var r_array:Array = new Array(-90,-90,-90,-90,-90,-90,-90,-90,-90,-90,-90,-90,-90,-90, -90, -90, -90, -90, -85, -75, 0, 75, 85, 90, 90, 90, 90, 90,90,90,90,90,90,90,90,90,90,90,90,90,90);
stage.scaleMode = "noScale";
//初期化
colors_array.reverse();
colors2_array.reverse();
for (i = 0; i < 21; i++) {
origin_array.push([[0,9,0,0], [[0, 0, 0],[-100, 0, -100],[100, 0, -100],[100, 0, 100],[-100, 0, 100],[100, 0, 300],[-100, 0, 300]]]);
}
for (i = 0; i < origin_array.length; i++) {
var mc:Sprite = new Sprite();
this.addChild(mc);
mc.x = 465/2;
mc.y = 240;
mc.addEventListener(MouseEvent.MOUSE_DOWN, MOUSE_DOWN);
mc.buttonMode = true;
sprits.push(mc);
}
for (i = 0; i<maisu; i++) {
var _obj:Object = {};
_obj.r = r_array[i+poz];
_obj.pozx = pozx_array[i+poz];
_obj.pozy = pozy_array[i+poz];
pt_array[i] = _obj;
}
addEventListener(Event.ENTER_FRAME,fn_move);
poz = 10;
//何度も使う系
function fc_create(arg_array:Array):void {
var i:uint = new uint(0);
var j:uint = new uint(0);
var k:uint = new uint(0);
//map
var data_array:Array = data_array = Math3D.fc_arraycopy(origin_array);
var dataarraylength_uint:uint = data_array.length;
//partsaffine
Math3D.fc_affinepart(data_array,pt_array);
//affine
Math3D.fc_affine(data_array,arg_array);
//sort
var z_array:Array = Math3D.zSort(pt_array);
///pertrance
for (i = 0; i<dataarraylength_uint; i++) {
for (j = 0; j<data_array[i][1].length; j++) {
data_array[i][1][j] = Math3D.pertrans(data_array[i][1][j]);
}
}
//render
for (k = 0; k<dataarraylength_uint; k++) {
var mc:Sprite = Sprite(sprits[k]);
mc.graphics.clear();
i = z_array[k];
if(-400 > data_array[i][1][0][0] || data_array[i][1][0][0] > 400){
continue;
}
if(-200 > data_array[i][1][0][0] || data_array[i][1][0][0] > 200){
mc.graphics.beginFill(colors2_array[i],0.9-(Math.abs(data_array[i][1][0][0])-200)/250);
}else{
mc.graphics.beginFill(colors2_array[i],1);
}
mc.graphics.moveTo(data_array[i][1][4][0],data_array[i][1][4][1]);
mc.graphics.lineTo(data_array[i][1][3][0],data_array[i][1][3][1]);
mc.graphics.lineTo(data_array[i][1][5][0],data_array[i][1][5][1]);
mc.graphics.lineTo(data_array[i][1][6][0],data_array[i][1][6][1]);
mc.graphics.lineTo(data_array[i][1][4][0],data_array[i][1][4][1]);
//
if(-200 > data_array[i][1][0][0] || data_array[i][1][0][0] > 200){
mc.graphics.beginFill(colors_array[i],0.9-(Math.abs(data_array[i][1][0][0])-200)/250);
}else{
mc.graphics.beginFill(colors_array[i],1);
}
mc.graphics.moveTo(data_array[i][1][4][0],data_array[i][1][4][1]);
for (j = 1; j<5; j++) {
mc.graphics.lineTo(data_array[i][1][j][0],data_array[i][1][j][1]);
}
mc.name = String(i);
}
}
function fn_move(e:Event = null):void {
for (var i:uint = 0; i<maisu; i++) {
pt_array[i].pozx = pt_array[i].pozx*0.8+pozx_array[i+poz]*0.2;
if ((maisu-1) == i+poz) {
pt_array[i].pozy = pt_array[i].pozy*0.85+pozy_array[i+poz]*0.15;
if (Math.abs(pt_array[i].pozy-pozy_array[i+poz]) < 1) {
return;
}
} else {
pt_array[i].pozy = pozy_array[i+poz];
}
pt_array[i].r = pt_array[i].r*0.8+r_array[i+poz]*0.2;
}
//
for (i = 0; i<poz_array.length; i++) {
anime_array[i] = anime_array[i]*(animestep_num-animecount_num)/animestep_num+poz_array[i]*animecount_num/animestep_num;
}
if (animecount_num < animestep_num) {
animecount_num ++;
} else {
animecount_num = 1;
}
fc_create(anime_array);
}
/////////////////////////
setNewSlider();
}
private function MOUSE_DOWN(e:MouseEvent):void{
ns.value = int(e.currentTarget.name);
poz = (20-int(e.currentTarget.name));
}
private function setNewSlider():void{
ns.x= 50+(465-stage.stageWidth)/2;
ns.y= 390;
ns.width = stage.stageWidth-100;
ns.maximum = 19;
ns.value = 10;
ns.liveDragging = true;
ns.addEventListener("change", onChange);
addChild(ns);
function onChange():void{
poz = 20-ns.value;
}
}
}
}
//
class Math3D
{
static public function zSort(pt_array:Array):Array{
var len:int = pt_array.length;
var sorter_array:Array = [];
for (var i:int = 0; i<len; i++) {
sorter_array[i] = 10000-pt_array[i].pozy;
}
return sorter_array.sort(Array.NUMERIC|Array.RETURNINDEXEDARRAY|Array.DESCENDING);
}
static public function pertrans(arg_array:Array):Array {
var _per:Number = 1000/(1000+arg_array[2]);
return [arg_array[0] * _per,arg_array[1] * _per,_per];
}
static public function fc_arraycopy(copy_array:Array):Array {
var _array:Array = new Array();
var i_array:Array = new Array();
var i:uint = new uint(0);
var j:uint = new uint(0);
for (i= 0; i<copy_array.length; i++) {
i_array[0] = copy_array[i][0].concat();
var j_array:Array = new Array();
for (j= 0; j<copy_array[i][1].length; j++) {
j_array[j] = copy_array[i][1][j].concat();
}
i_array[1] = j_array.concat();
_array[i] = i_array.concat();
}
return _array;
}
static public function fc_affine(data_array:Array,arg_array:Array):Array {
var n_cx:Number = Math.cos(arg_array[3]);
var n_sx:Number = Math.sin(arg_array[3]);
var n_cy:Number = Math.cos(arg_array[4]);
var n_sy:Number = Math.sin(arg_array[4]);
var n_cz:Number = Math.cos(arg_array[5]);
var n_sz:Number = Math.sin(arg_array[5]);
var _array:Array = new Array(15);
_array[3] = arg_array[0];
_array[4] = arg_array[1];
_array[5] = arg_array[2];
_array[6] = n_cz*n_cy+n_sx*n_sy*n_sz;
_array[7] = n_sx*n_sy*n_cz-n_sz*n_cy;
_array[8] = n_sy*n_cx;
_array[9] = n_cx*n_sz;
_array[10] = n_cx*n_cz;
_array[11] = -n_sx;
_array[12] = n_cy*n_sx*n_sz-n_sy*n_cz;
_array[13] = n_sy*n_sz+n_cy*n_sx*n_cz;
_array[14] = n_cx*n_cy;
var dataarraylength_uint:uint = new uint(data_array.length);
for (var i:uint = 0; i<dataarraylength_uint; i++) {
var dataarrayi1length_uint:uint = new uint(data_array[i][1].length);
for (var j:uint = 0; j<dataarrayi1length_uint; j++) {
_array[0] = data_array[i][1][j][0];
_array[1] = data_array[i][1][j][1];
_array[2] = data_array[i][1][j][2];
for (var k:uint = 0; k<3; k++) {
data_array[i][1][j][k] = _array[0]*_array[6+3*k]+_array[1]*_array[7+3*k]+_array[2]*_array[8+3*k]+_array[k+3];
}
}
}
return data_array;
}
static public function fc_affinepart(data_array:Array,pt_array:Array):Array {
var dataarraylength_uint:uint = new uint(data_array.length);
for (var i:uint = 0; i<dataarraylength_uint; i++) {
var n_cx:Number = Math.cos(-Math.PI/2);
var n_sx:Number = Math.sin(-Math.PI/2);
var n_cy:Number = Math.cos(pt_array[i].r/60);
var n_sy:Number = Math.sin(pt_array[i].r/60);
var n_cz:Number = Math.cos(0);
var n_sz:Number = Math.sin(0);
var _array:Array = new Array(15);
_array[3] = pt_array[i].pozx;
_array[4] = 0;
//_array[4] = -this.pt_array[i].pozz;
_array[5] = -pt_array[i].pozy;
_array[6] = n_cz*n_cy+n_sx*n_sy*n_sz;
_array[7] = n_sx*n_sy*n_cz-n_sz*n_cy;
_array[8] = n_sy*n_cx;
_array[9] = n_cx*n_sz;
_array[10] = n_cx*n_cz;
_array[11] = -n_sx;
_array[12] = n_cy*n_sx*n_sz-n_sy*n_cz;
_array[13] = n_sy*n_sz+n_cy*n_sx*n_cz;
_array[14] = n_cx*n_cy;
var dataarrayi1length_uint:uint = new uint(data_array[i][1].length);
for (var j:uint = 0; j<dataarrayi1length_uint; j++) {
_array[0] = data_array[i][1][j][0];
_array[1] = data_array[i][1][j][1];
_array[2] = data_array[i][1][j][2];
for (var k:uint = 0; k<3; k++) {
data_array[i][1][j][k] = _array[0]*_array[6+3*k]+_array[1]*_array[7+3*k]+_array[2]*_array[8+3*k]+_array[k+3];
}
}
}
return data_array;
}
}
//UICompo
import flash.display.Sprite;
//import fl.core.UIComponent
import flash.events.Event;
import flash.events.MouseEvent;
class UICompo extends Sprite {
private var _enabled:Boolean = true;
public function get enabled():Boolean { return _enabled; }
public function set enabled(value:Boolean):void {
_enabled = value;
}
override public function get width():Number { return super.width; };
override public function set width(value:Number):void {
super.width = value;
_resize();
};
override public function get scaleX():Number { return super.scaleX; };
override public function set scaleX(value:Number):void {
super.scaleX = value;
};
public var resize:Function = function(e:Event = null):void{};
public var _resize:Function = function(e:Event = null):void{resize(e)};
}
class NewSlider extends UICompo {
override public function get enabled():Boolean { return super.enabled; }
override public function set enabled(value:Boolean):void
{
if (value) {
this.alpha = 1;
}else{
this.alpha = 0.5;
isThis = false;
wideRemoveEventListener(this, Event.ENTER_FRAME, ENTER_FRAME);
}
super.enabled = value;
}
private var _maximum:Number = 10;
private var _minimum:Number = 0;
private var _value:Number = 0;
//private var isButtonDown:Boolean;
private var _moverbleWidth:Number = 80;
private var thumb:Sprite = Create.newSprite(null, null, [["beginFill", [0x858788, 1]], ["moveTo", [0, 0]], ["lineTo", [6, 9]], ["lineTo", [6, 11]], ["lineTo", [4, 13]], ["lineTo", [-4, 13]], ["lineTo", [-6, 11]], ["lineTo", [-6, 9]]]);
private var _thumb:Sprite = new Sprite();
private var sp:UICompo = new UICompo();
public var liveDragging:Boolean;
private var isThis:Boolean;
public var snapInterval:Number = 1;
function NewSlider(){
makeGraphicPart();
thumb.addChild(Create.newSprite(null, null, [["beginFill", [0xebebeb, 1]], ["moveTo", [0, 1]], ["lineTo", [5, 9]], ["lineTo", [5.5, 10]], ["lineTo", [3, 12]], ["lineTo", [ -3, 12]], ["lineTo", [ -5.5, 10]], ["lineTo", [ -5, 9]]]))
_resize = function(e:Event = null):void {
_moverbleWidth = width;
makeGraphicPart();
};
this.addEventListener(MouseEvent.MOUSE_DOWN, MOUSE_DOWN);
this.addEventListener(Event.ADDED_TO_STAGE, ADDED_TO_STAGE);
this.addEventListener(Event.REMOVED_FROM_STAGE, REMOVED_FROM_STAGE);
this.addEventListener(MouseEvent.MOUSE_MOVE, MOUSE_MOVE);
this.addChild(sp);
}
private function ADDED_TO_STAGE(e:Event):void {
stage.addEventListener(MouseEvent.MOUSE_UP, MOUSE_UP);
stage.addEventListener(KeyboardEvent.KEY_DOWN,KEY_DOWN);
}
private function REMOVED_FROM_STAGE(e:Event):void {
wideRemoveEventListener(this, Event.ENTER_FRAME, ENTER_FRAME);
for (var i:int = 0; i < eventListenerList.length; i++) {
wideRemoveEventListener(eventListenerList[i][0],eventListenerList[i][1],eventListenerList[i][2]);
//wideRemoveEventListener.apply(eventListenerList[i]);??
}
eventListenerList = [];
isThis = false;
stage.removeEventListener(MouseEvent.MOUSE_UP, MOUSE_UP);
}
private var change:Function = function(e:Event = null):void{};
private var thumbDrag:Function = function(e:Event = null):void{};
private var eventListenerList:Array = new Array();
private function KEY_DOWN(e:KeyboardEvent):void{
if(e.keyCode == 39){
value ++;
change(e);
}else if(e.keyCode == 37){
value --;
change(e);
}
}
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
if (type == "thumbPress" || type == "thumbRelease") {
eventListenerList.push([thumb, type, listener]);
thumb.addEventListener(MouseEvent.MOUSE_DOWN, listener);
}else if (type == "change" || type == "thumbDrag") {
this[type] = listener;
}else {
super.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
}
private function makeGraphicPart():void {
for (var i:int = 0; i < sp.numChildren; i++) {
sp.removeChildAt(0);
}
sp.addChild(Create.newShape(null,null,[["beginFill",[0x8c9295,1]],["drawRoundRect",[0,0,_moverbleWidth+1,4,4]]]));
sp.addChild(Create.newShape(null, null, [["beginFill", [0xebebeb, 1]], ["drawRoundRect", [1, 1, _moverbleWidth-1, 2, 2]]]));
sp.addChild(thumb);
scaleX = 1;
}
private function thumbMove(e:Event = null):void {
var _x:Number = Math.max(Math.min(this.mouseX, (_moverbleWidth)), 0);
if (thumb.x != thumbXFromMouseX(_x)) {
_x = thumbXFromMouseX(_x);
thumb.x = _x;
value = (_x / _moverbleWidth) * (_maximum - _minimum);
if(liveDragging){
change(e);
}
}
}
private function thumbXFromMouseX(_x:Number):Number {
_x = Math.round((_x / _moverbleWidth) * (_maximum - _minimum) / snapInterval) * snapInterval;
_x = _moverbleWidth * _x / (_maximum - _minimum);
return _x;
}
private function MOUSE_UP(e:MouseEvent):void {
//isButtonDown = e.buttonDown;
if (!enabled) { return };
if(isThis && !liveDragging){
change(e);
}
isThis = false;
wideRemoveEventListener(this, Event.ENTER_FRAME, ENTER_FRAME);
}
private function MOUSE_DOWN(e:MouseEvent):void {
if (!enabled) { return };
isThis = true;
wideRemoveEventListener(this, Event.ENTER_FRAME, ENTER_FRAME);
this.addEventListener(Event.ENTER_FRAME, ENTER_FRAME);
};
private function MOUSE_MOVE(e:MouseEvent):void { };
private function wideRemoveEventListener(_target:*,type:String, listener:Function):void {
if (_target.hasEventListener(type)) {
_target.removeEventListener(type, listener);
}
}
private function ENTER_FRAME(e:Event):void {
thumbMove(e);
thumbDrag(e);
}
public function get maximum():Number {return _maximum; };
public function set maximum(value:Number):void {
_maximum = value;
};
public function get minimum():Number {return _minimum; };
public function set minimum(value:Number):void {
_minimum = value;
};
public function get value():Number {return _value; };
public function set value(value:Number):void {
if (_value != setValue(value)) {
_value = setValue(value);
thumb.x = (_value * _moverbleWidth) / (_maximum - _minimum);
}
};
private function setValue(value:Number):Number {
value = Math.min(Math.max(value, minimum), maximum);
value = Math.round(value / snapInterval) * snapInterval;
return value;
};
private var _tickInterval:Number = 0;
public function get tickInterval():Number {
return _tickInterval;
}
public function set tickInterval(value:Number):void {
this.graphics.clear();
if (value) {
_tickInterval = value;
value = (_maximum - _minimum) / value;
for (var i:int = 0; i < Math.floor(value)+1; i++) {
this.addChild(Create.newShape(null,null,[["beginFill",[0xCCCCCC,1]],["drawRect",[(_moverbleWidth/value)*i-1,-4,2,2]]]));
}
}
}
}
import flash.display.DisplayObject;
import flash.display.Graphics;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.events.KeyboardEvent;
class Create{
public static var defaultTextFormat:TextFormat = new TextFormat();
public static function newSimpleButton(x_y_w_h_txt:Array = null,property:Array=null,graphics:Array=null):SimpleButton{
var upState:Sprite = newSprite([x_y_w_h_txt[0],x_y_w_h_txt[1]],null,[["beginFill",[0xCCCCCC,1]],["drawRoundRect",[0,0,x_y_w_h_txt[2],x_y_w_h_txt[3],8]]]);
upState.addChild(newShape([2,2],null,[["beginFill",[0xE5E5E5,1]],["drawRoundRect",[0,0,x_y_w_h_txt[2]-4,x_y_w_h_txt[3]-4,6]]]))
var overState:Sprite = newSprite([x_y_w_h_txt[0],x_y_w_h_txt[1]],null,[["beginFill",[0xBBBBBB,1]],["drawRoundRect",[0,0,x_y_w_h_txt[2],x_y_w_h_txt[3],8]]]);
overState.addChild(newShape([2,2],null,[["beginFill",[0xEEEEEE,1]],["drawRoundRect",[0,0,x_y_w_h_txt[2]-4,x_y_w_h_txt[3]-4,6]]]))
var downState:Sprite = newSprite([x_y_w_h_txt[0],x_y_w_h_txt[1]],null,[["beginFill",[0xAAAAAA,1]],["drawRoundRect",[0,0,x_y_w_h_txt[2],x_y_w_h_txt[3],8]]]);
downState.addChild(newShape([2,2],null,[["beginFill",[0xDDDDDD,1]],["drawRoundRect",[0,0,x_y_w_h_txt[2]-4,x_y_w_h_txt[3]-4,6]]]))
var hitTestState:Shape = newShape([x_y_w_h_txt[0],x_y_w_h_txt[1]],null,[["beginFill",[0,1]],["drawRoundRect",[0,0,x_y_w_h_txt[2],x_y_w_h_txt[3],8]]]);
if(x_y_w_h_txt[4]){
upState.addChild(newTextField([0,2,x_y_w_h_txt[2],x_y_w_h_txt[3]-2],[["defaultTextFormat",new TextFormat("_sans", null, null, null, null, null, null, null, "center")],["text",x_y_w_h_txt[4]]]));
overState.addChild(newTextField([0,2,x_y_w_h_txt[2],x_y_w_h_txt[3]-2],[["defaultTextFormat",new TextFormat("_sans", null, null, null, null, null, null, null, "center")],["text",x_y_w_h_txt[4]]]));
downState.addChild(newTextField([0,3,x_y_w_h_txt[2],x_y_w_h_txt[3]-3],[["defaultTextFormat",new TextFormat("_sans", null, null, null, null, null, null, null, "center")],["text",x_y_w_h_txt[4]]]));
}
var sb:SimpleButton = new SimpleButton(upState,overState,downState,hitTestState);
return sb;
}
public static function newShape(x_y_w_h_sh:Array = null,property:Array=null,graphics:Array=null):Shape{
var i:int;
var sh:Shape;
if(x_y_w_h_sh && x_y_w_h_sh[4]){
sh = x_y_w_h_sh[4];
}else{
sh = new Shape();
}
if(x_y_w_h_sh){
if (x_y_w_h_sh[0]) { sh.x = x_y_w_h_sh[0] };
if (x_y_w_h_sh[1]) { sh.y = x_y_w_h_sh[1] };
}
if(property){
for (i = 0; i < property.length; i++) {
if(property[i] && property[i].length > 1){
sh[property[i][0]] = property[i][1];
}
}
}
if(graphics){
for (i = 0; i < graphics.length; i++) {
if(graphics[i] && graphics[i].length > 1){
sh.graphics[graphics[i][0]].apply(null, graphics[i][1]);
}
}
}
if(x_y_w_h_sh){
if (x_y_w_h_sh[2]) { sh.width = x_y_w_h_sh[2] };
if (x_y_w_h_sh[3]) { sh.height = x_y_w_h_sh[3] };
}
return sh;
}
public static function newSprite(x_y_w_h_sp:Array = null,property:Array=null,graphics:Array=null,addChild:DisplayObject = null):Sprite{
var i:int;
var sp:Sprite;
if(x_y_w_h_sp && x_y_w_h_sp[4]){
sp = x_y_w_h_sp[4];
}else{
sp = new Sprite();
}
if(x_y_w_h_sp){
if (x_y_w_h_sp[0]) { sp.x = x_y_w_h_sp[0] };
if (x_y_w_h_sp[1]) { sp.y = x_y_w_h_sp[1] };
}
if(property){
for (i = 0; i < property.length; i++) {
if(property[i] && property[i].length > 1){
sp[property[i][0]] = property[i][1];
}
}
}
if(graphics){
for (i = 0; i < graphics.length; i++) {
if(graphics[i] && graphics[i].length > 1){
sp.graphics[graphics[i][0]].apply(null, graphics[i][1]);
}
}
}
if(addChild){
sp.addChild(addChild);
}
if(x_y_w_h_sp){
if (x_y_w_h_sp[2]) { sp.width = x_y_w_h_sp[2] };
if (x_y_w_h_sp[3]) { sp.height = x_y_w_h_sp[3] };
}
return sp;
}
public static function newTextField(x_y_w_h_txt_color_alpha:Array = null,property:Array=null,method:Array=null):TextField{
var i:int;
var ta:TextField = new TextField();
ta.defaultTextFormat = defaultTextFormat;
if(x_y_w_h_txt_color_alpha){
if (x_y_w_h_txt_color_alpha[0]) { ta.x = x_y_w_h_txt_color_alpha[0] };
if (x_y_w_h_txt_color_alpha[1]) { ta.y = x_y_w_h_txt_color_alpha[1] };
if (x_y_w_h_txt_color_alpha[2]) { ta.width = x_y_w_h_txt_color_alpha[2] };
if (x_y_w_h_txt_color_alpha[3]) { ta.height = x_y_w_h_txt_color_alpha[3] };
if (x_y_w_h_txt_color_alpha[4]) { ta.text = x_y_w_h_txt_color_alpha[4] };
if (x_y_w_h_txt_color_alpha[5]) { ta.textColor = x_y_w_h_txt_color_alpha[5] };
if (x_y_w_h_txt_color_alpha[6]) { ta.alpha = x_y_w_h_txt_color_alpha[6] };
}
if(property){
for (i = 0; i < property.length; i++) {
if(property[i] && property[i].length > 1){
ta[property[i][0]] = property[i][1];
}
}
}
if(method){
for (i = 0; i < method.length; i++) {
if(method[i] && method[i].length > 1){
ta[method[i][0]].apply(null, method[i][1]);
}
}
}
return ta;
}
}