だいぶ前に腕試しにつくったもの。当時はbitmap画像をパースを付けてキレイに貼付ける方法がわからなかったので、とりあえず色面が動くようにしてみた。動きは基本的にはiTunesのCoverFlowを目コピなわけだけど、やっぱりこういうUIは自然に扱えるように細かいところで工夫されているんだと改めて感心した。
あ、あとSliderは今回自作したもの。やっぱこういうUIは(略
Colorflow – wonderfl build flash online
▼ActionScript AS3(FP9)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
/* 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; } } |