アーカイブ

‘function’ タグのついている投稿

JSFL 個別にランダム変形するJSFLを作ってみた ver0.1

2009 年 7 月 31 日 コメントはありません
選択したMCなど、基準点を基準にてランダムで変形するJSFLを作ってみました。

1.MCなどを複数選択して、



2.JSFLを実行すると、縦横それぞれの拡大縮小させる最大値と最小値の範囲を設定します。



3.以下のようにランダムで変形します。



初めて作ったので、完成度は低いかもしれませんが、今後、細かい設定とmxpなどにしていきたいと思います。

JSFLのソースは以下の様になりました。
非公式JSFLとMXPのまとめページを作成予定。

if(fl.getDocumentDOM().selection[0] != null){
	randomTransform();
}
 
function randomTransform(){
	var hMin = Number(prompt("縦の最小値(%)", "60"));
	var hMax = Number(prompt("縦の最大値(%)", "200"))-hMin;
 
	var wMin = Number(prompt("横の最小値(%)", "60"));
	var wMax = Number(prompt("横の最大値(%)", "200"))-wMin;
 
 
	for(var i = 0; i<fl.getDocumentDOM().selection.length; i++){
			var target = fl.getDocumentDOM().selection[i];
			target.scaleX = Math.round(Math.random()*hMax+hMin)/100;
			target.scaleY = Math.round(Math.random()*hMax+wMin)/100;
	}
}

Progression this の扱い(Q) 無名関数, Func, function

2009 年 7 月 20 日 コメントはありません
Progression this の扱い(破) 無名関数, Func, functionの続き。

Progressionクラスを生成し、コンストラクタで”id”を指定します。

this.id = "yaimo";
trace("クラスのid: "+this.id);
//出力:クラスのid: yaimo
trace("普通にthis: "+this);
//出力:[IndexScene sceneId="/index" id="yaimo" name="index" group="null"]


今回はSerialList.addCommand()内でのthisの扱いについて、全体のコードはこんな感じです。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var sList:SerialList = new SerialList();
			sList.id = "sList";
			sList.addCommand(
				//[		
				new Trace("SerialList.addCommand内でのthis.id: " + this.id),
				new Func(function ():void 
				{
					trace("SerialList.addCommand内でのthis" + this);
					trace("SerialList.addCommand内でのthis.parent" + this.parent);
					this.id = "Function";
					trace("SerialList.addCommand内でのthis.id: " + this.id);
				}),
				function ():void 
				{
					trace("SerialList.addCommand内でのthis.parent" + this.parent.id);
					this.parent.insertCommand(new Trace("追加1"));
					insertCommand(new Trace("追加2"));
				},
 
				[//ここからParallelList
				new Func(function ():void 
				{
					trace("SerialList.addCommand内でのthis: " + this);
					trace("SerialList.addCommand内でのthis.parent" + this.parent);
				}),
				],

全体の出力結果です。

SerialList.addCommand内でのthis.id: yaimo
 
SerialList.addCommand(コード)での実験------new Func()---------
SerialList.addCommand内でのthis[Func id="null" name="command_47" group="null"]
SerialList.addCommand内でのthis.parent[SerialList id="sList" name="command_42" group="null"]
SerialList.addCommand内でのthis.id: Function
-------------------------------------------------------------
 
SerialList.addCommand(コード)での実験-----function()----------
SerialList.addCommand内でのthis.parentsList
-------------------------------------------------------------
追加1
 
SerialList.ddCommand([コード])での実験-----new Func()----------
SerialList.addCommand内でのthis: [Func id="null" name="command_48" group="null"]
SerialList.addCommand内でのthis.parent[ParallelList id="null" name="command_54" group="null"]
-------------------------------------------------------------





基本は前回とほとんど同じなので省きます。
それで注目したいのが、10行目の

trace("SerialList.addCommand内でのthis.parent" + this.parent);

での出力が

SerialList.addCommand内でのthis.parent[SerialList id="sList" name="command_42" group="null"]

でthis.parentの参照がsListになることです。
なので、19,20行目のthis.parentでsListにinsertCommandによる挿入を行わないと思ったとおりの実行をしてくれません。
“追加1”の実行されるタイミングはfunctionのCommandが終わってから。
“追加2″はおそらく、クラスに定義されているaddCommand(){}に登録されるんじゃないかと思われます。

【まとめ】
  • new Func(function:void{}),function():void{}内でのthisはFuncクラスを指す

  • SerialList.addCommand(){}の場合、function():void{this.parent}はSerialListを指す。

Progression this の扱い(破) 無名関数, Func, function

2009 年 7 月 19 日 コメントはありません
Progression this の扱い(序) 無名関数, Func, functionの続き。

Progressionクラスを生成し、コンストラクタで”id”を指定します。

this.id = "yaimo";
trace("クラスのid: "+this.id);
//出力:クラスのid: yaimo
trace("普通にthis: "+this);
//出力:[IndexScene sceneId="/index" id="yaimo" name="index" group="null"]


今回はaddCommand()内でのthisの扱いについて、全体のコードはこんな感じです。

addCommand(
				new Trace("addCommand内でのthis.id: " + this.id),
				new Func(function ():void
				{
					trace("addCommand内でのthis" + this);
					trace("addCommand内でのthis.parent" + this.parent);
					this.id = "Function";
					trace("addCommand内でのthis.id: " + this.id);
					trace("addCommand内でのthis.parent.id: " + this.parent.id);
					this.parent.id = "parentはSerialList";
					trace("addCommand内でのthis.parent" + this.parent);
				}),
				function ():void
				{
					trace("addCommand内でのthis" + this);
					trace("addCommand内でのthis.parent" + this.parent);
					this.id = "fuction";
					trace("addCommand内でのthis.id: " + this.id);
					trace("addCommand内でのthis.parent.id: "+this.parent.id);
				},
				[//ここからParallelList
				new Func(function ():void
				{
					trace("addCommand内でのthis" + this);
					trace("addCommand内でのthis.parent" + this.parent);
					this.id = "Function";
					trace("addCommand内でのthis.id: "+this.id);
					trace("addCommand内でのthis.parent.id: "+this.parent.id);
				}),
				]
			);

続きを読む…

Progression this の扱い(序) 無名関数, Func, function

2009 年 7 月 18 日 コメントはありません
ProgressionのCommand時におけるthisの参照の違いと、無名関数におけるブロックスコープとthisの参照について考える。

Progressionクラスを生成し、コンストラクタで”id”を指定します。

this.id = "yaimo";
trace("クラスのid: "+this.id);
//出力:クラスのid: yaimo
trace("普通にthis: "+this);
//出力:[IndexScene sceneId="/index" id="yaimo" name="index" group="null"]

まずはじめに無名関数におけるthisの扱いから、

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
private function hoge():void
		{
			var target:MovieClip = new MovieClip();
			trace("普通の関数内でのthis.id: "+this.id);
 
			target.addEventListener(MouseEvent.MOUSE_OUT,function ():void
			{
				trace("無名関数内でのtarget: "+target);
				trace("単純にthis: " + this);
				trace("ではthis.parent: " + this.parent);
				trace("無名関数内でのthis.id: " + this.id);
				trace("無名関数内でのthis.target: " + this.target);
				this.id = "this.idは無名関数内のidとして登録されています。";
				trace("登録後のthis: "+this.id);
			});

続きを読む…