【サンプル】
サンプルでは緑とピンクの表示オブジェクトをテーブルに配置してます。
ドラッグ&ドロップで移動入れ替えが可能です。
クリックと移動を行った際に対象のセル座標を表示してます。
This movie requires Flash Player 9
DisplayObjectTableクラスのDLはこちら
使用例
package { import flash.display.DisplayObject; import flash.display.Sprite; import flash.events.Event; import flash.text.TextField; import flash.text.TextFieldAutoSize; import org.highangle.ui.DisplayObjectTable.*; public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point //テーブルに配置するオブジェクトを生成 var test:Sprite = new Sprite(); test.graphics.beginFill(0xff8888, 0.5); test.graphics.drawRect(0, 0, 500, 400); test.graphics.endFill(); var test2:Sprite = new Sprite(); test2.graphics.beginFill(0x88ff88, 0.5); test2.graphics.drawRect(0, 0, 500, 400); test2.graphics.endFill(); //テーブルオブジェクトの生成 var t:DisplayObjectTable = new DisplayObjectTable(4, 3, 80, 80); addChild(t); //テーブルに配置する t.add(0, 0, test); t.add(0, 1, test2); //以下イベントメッセージの表示など var tf:TextField = new TextField(); tf.autoSize = TextFieldAutoSize.LEFT; addChild(tf); //クリックされたとき t.addEventListener(Event.SELECT, function():void { tf.text = 'selected at ' + t.selected; } ); //ドラッグで移動したとき t.addEventListener(Event.CHANGE, function():void { tf.text = 'replaced from ' + t.selected; tf.text += '\nreplaced to '+ t.destination; } ); } } }
最近のコメント