他インスタンスでも同クラスならprivateにアクセスできる
これの検証 http://twitter.com/bkzen/statuses/6194550947
/**
* Copyright keno42 ( http://wonderfl.net/user/keno42 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/4PgI
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
// これの検証 http://twitter.com/bkzen/statuses/6194550947
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var obj1:myClass = new myClass();
obj1.myName = "他人";
var obj2:myClass = new myClass();
obj2.myName = "自分";
var tf:TextField = new TextField();
addChild(tf);
tf.text = obj2.otherClass(obj1);
}
}
}
class myClass{
private var _myName:String = "";
public function set myName(value:String):void{ _myName = value; }
public function otherClass(obj:myClass):String{
return _myName + ", " + obj._myName;
}
}