どれをクリックしたかわかるようにする
http://d.hatena.ne.jp/ymko/20090720#1248538039 のリベンジ。
apeirophobia: addEventListenerで一緒に引数を渡したい
http://blog.img8.com/archives/2008/04/003758.html
アクティベーションオブジェクトによるメモリリーク (www.imajuk.swf)
http://www.imajuk.com/blog/archives/2008/04/post_3.html
気をつけないとメモリリークするらしい。
// 表示&マウスクリック時のイベント定義 for (var j:int = 1; j <= 9; j++) { var sprite:Sprite = img_manz[j]; sprite.x = j * 30; sprite.addEventListener(flash.events.MouseEvent.CLICK,onClick3(String(j))); function onClick3(str:String) :Function{ return function (e:MouseEvent):void{; //trace("str",str); //trace(e.target.name); onClick(str); } ; } addChild(sprite); } 〜 private function onClick(str:String): void { trace("click" + str);// どれクリックされたかわかる! }