thisの件
♥0 |
Line 47 |
Modified 2009-06-08 19:12:01 |
MIT License
archived:2017-03-20 11:56:02
ActionScript3 source code
/**
* Copyright nacookan ( http://wonderfl.net/user/nacookan )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/2vnW
*/
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
public class ThisInFunction extends Sprite {
var t:TextField;
public function ThisInFunction():void {
var f:TextFormat = new TextFormat();
f.font = 'sans';
f.size = 20;
f.color = 0x333333;
t = new TextField();
t.defaultTextFormat = f;
t.autoSize = TextFieldAutoSize.LEFT;
t.multiline = true;
addChild(t);
var func:Function = (function():void{
t.text += this + '\n';
});
t.text = '-- load --\n';
t.text += this + '\n';
func();
func.apply(this);
hoge();
hoge.apply(this);
var s:Sprite = new Sprite();
s.graphics.lineStyle(2, 0x333333);
s.graphics.beginFill(0x88aaff);
s.graphics.drawRoundRect(0, 0, 100, 100, 12);
s.graphics.endFill();
s.x = stage.stageWidth - s.width;
s.y = stage.stageHeight - s.height;
s.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void{
t.text += '-- click --\n';
t.text += this + '\n';
func();
func.apply(this);
hoge();
hoge.apply(this);
});
addChild(s);
}
function hoge(){
t.text += this + '\n';
}
}
}