1月 02

as3で表示オブジェクト専用テーブル

【サンプル】
サンプルでは緑とピンクの表示オブジェクトをテーブルに配置してます。
ドラッグ&ドロップで移動入れ替えが可能です。
クリックと移動を行った際に対象のセル座標を表示してます。

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;
			} );
			
		}
	}
}

11月 24

AS3でカレンダークラス

今、業務で使うwebアプリを作ってまして
日付を入力するUIが必要だったので、
カレンダーUIを表示するクラスを作って見ました。

This movie requires Flash Player 9

CalendarクラスのDLはこちら

使い方↓

tf.autoSize = TextFieldAutoSize.LEFT;
addChild(tf);

var calendar:Calendar = new Calendar();
addChild(calendar);
calendar.y = 30;
calendar.scaleX = 2;
calendar.scaleY = calendar.scaleX;

calendar.addEventListener(Event.SELECT, function(e:Event):void {
	tf.text = calendar.date.toString();
});

■ 解説
・日付をクリックするとSELECTイベントが叩かれます。
・日時情報を得るにはcalendar.dateにアクセスします。(date型です)

11月 18

as3 タブメニューパネル

作ってみました。
flashPlayer9以上

This movie requires Flash Player 9

TabPanelクラスのDLはこちら

↓使い方

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 tab:TabPanel = new TabPanel(520,420, 0xf0f0f0);
tab.addPanel(test, 'てすとてすと');
tab.addPanel(test2, 'テストテストテスト');
addChild(tab);

■ 解説

  1. new TabPanel インスタンスを作成して初期値(サイズとカラー)を入れます。
  2. tab.addPanel 第一引数は貼り付けるdisplayObject、第二引数はタブに表示されるテキスト
  3. addChildして終了

» 新しい記事へ