msec : value = this['nest']['nest']['value'];
enabled
これを使えば、クラスパスを文字列として保存しておき、後から参照することが可能です。
// use
var list:Array= "nest.nest.nest.value".split(".");
this[list[0]][list[1]][list[2]][list[3]]
♥0 |
Line 204 |
Modified 2016-06-13 00:40:48 |
MIT License
archived:2017-03-20 03:33:57
ActionScript3 source code
/**
* Copyright 110100110101101 ( http://wonderfl.net/user/110100110101101 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sARK
*/
package {
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
addChild( new Test() );
}
}
}
class Nest
{
public var value:Number = 1;
public var nest:Nest;
}
import flash.utils.Dictionary;
import flash.display.Sprite;
import flash.utils.Dictionary;
class Test extends Sprite
{
private var nest:Nest;
public function Test()
{
var object:Object = new Object();
var dictionary:Dictionary = new Dictionary();
var array:Array = new Array();
var xml:XML;
var xmlList:XMLList;
object["value"] = 0;
dictionary["value"] = 0;
array[0] = 0;
xml =
<xml>
<value>0</value>
<xmlList>
<value>0</value>
</xmlList>
</xml>
xmlList = xml.xmlList;
var value:int = 0;
var _value:int = 0;
var note:LLLNote = new LLLNote(this);
var i:int,iMax:int = 1000000;
note.text = "\n";
nest = new Nest();
nest.nest = new Nest();
nest.nest.nest = new Nest();
note.start("");
for(i=0;i<iMax;++i)
{
value = nest.value;
}
note.end(" msec: value = nest.value; //"+value.toString()+"\n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = nest['nest'].value;
}
note.end(" msec: value = nest['nest'].value; //"+value.toString()+"\n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = nest['nest']['nest'].value;
}
note.end(" msec: value = nest['nest']['nest'].value; //"+value.toString()+"\n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = this['nest']['nest'].value;
}
note.end(" msec: value = this['nest']['nest'].value; //"+value.toString()+"\n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = this['nest']['nest']['value'];
}
note.end(" msec: value = this['nest']['nest']['value']; //"+value.toString()+"\n" );
note.start("---------------------------\n");
for(i=0;i<iMax;++i)
{
value = _value;
}
note.end(" msec: value = _value; \n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = array[0];
}
note.end(" msec: value = array[0]; \n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = array[array.indexOf(0)];
}
note.end(" msec: value = array[array.indexOf(0)]; \n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = object.value;
}
note.end(" msec: value = object.value; \n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = dictionary.value;
}
note.end(" msec: value = dictionary.value; \n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = xml.value;
}
note.end(" msec: value = xml.value; \n" );
note.start("");
for(i=0;i<iMax;++i)
{
value = xmlList.value;
}
note.end(" msec: value = xmlList.value; \n" );
}
}
/////////////////////////////////////////////////////////////////////
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.DisplayObjectContainer;
import flash.events.Event;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.utils.getTimer;
/**
表示だけなら1行で書ける形の着想元
! MinimalComps の com.bit101.components.Component
https://github.com/minimalcomps/minimalcomps/blob/master/src/com/bit101/components/Component.as
*/
class LLLNote extends Sprite {
public function LLLNote( parent:DisplayObjectContainer=null, text:String=" ", x:Number=0,y:Number=0,widthX:Number=200,widthY:Number=100 ){
initialize( parent, text, x, y, widthX, widthY );
}
public function initialize( parent:DisplayObjectContainer=null, text:String=" ", x:Number=0,y:Number=0,widthX:Number=200,widthY:Number=100 ):void{
shape = new Shape();
bitmap = new Bitmap( new BitmapData( 1,1, true, 0x00000000 ) );
textFormat = new TextFormat()
textFormat.leftMargin = 0
textFormat.rightMargin = 0
textFormat.align = "left"
textFormat.font = "_等幅" //EXAMPLE "_等幅" "_ゴシック" "_明朝 " "_typewriter" "_serif" "_sans"
textFormat.size = 10
textField = new TextField()
textField.background = false;
textField.backgroundColor = 0xFFFFFF;
textField.border = false;
textField.borderColor = 0x000000;
textField.textColor = 0x000000;
textField.autoSize = "left";
textField.selectable = false;
textField.text = text;
textField.defaultTextFormat = textFormat;
this.text = text;
this.x = x;
this.y = y;
//textField.width = widthX;
//textField.height = widthY;
addParent( parent );
addEventListener( Event.ENTER_FRAME, _onEnterFrame );
}
private function _onEnterFrame( event:Event ):void { textField.text = text; }
public function create():LLLNote{
return new LLLNote();
}
public function addParent( parent:DisplayObjectContainer ):void{
if( parent ){
parent.addChild( this );
addChild( textField );
addChild( shape );
addChild( bitmap );
}
}
public function removeParent( parent:DisplayObjectContainer ):void{
if( parent ){
parent.removeChild( this );
removeChild( textField );
removeChild( shape );
removeChild( bitmap );
}
}
public function start( startText:String = "" ):void{
startTime = getTimer();
text = text + startText;
}
public function end( endText:String = "" ):void{
endTime = getTimer();
elapsedTime = endTime - startTime;
text = text + elapsedTime.toString() + endText;
}
public function toBitmapData():BitmapData{
var result:BitmapData
result = new BitmapData( this.width, this.height, true, 0x00000000 );
result.draw( this );
return result;
}
public var elapsedTime:Number = 0;
public var endText:String = "";
public var endTime:Number = 0;
public var iMax:uint = 1000000;
public var startText:String = "";
public var startTime:Number = 0;
public var text:String
public var textFormat:TextFormat
public var textField:TextField
public var bitmap:Bitmap;
public var shape:Shape
}