アーカイブ

2009 年 7 月 のアーカイブ

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

続きを読む…

Flash Lite 入門 初心者が読んでおきたい記事

2009 年 7 月 17 日 コメントはありません
携帯Flashコンテンツを初めて作ることになりました。
まったく携帯Flashを開発したことがないFlasherが読んどいた方がいい事前知識などです。

携帯FlashのデバッグアプリAdobe Device Centralを起動したら「この製品のライセンシングが動作していません。」
などというけったいなエラーが出てデバッグができないということに。


初めてFlash Liteをやるにあたって読むとためになる記事は以下
まずは、FlashLiteの現状とキャリアに対しての記事。
そして実際にターゲットを絞って開発する際などにどうすればいいかなどの参考になる。


version1.1 で実際に制作する際に、サイズはどうすればいい。フレームレートは?などといった疑問が解決される記事


Flash Liteは制限があるために以下にファイルの容量を計量するかというノウハウが必要になってきます。


携帯は上下キーどちらか押されたかの判別は難しい。普段PCとは縁のないノウハウが必要です。


Flash LiteにはtellTargetというものがあるのですが、その概念のイメージがつかみにくいと思います。
このエントリーのおかげで解決!するでしょう。


さらに、注意したいポイント


携帯フラッシュでかなりの確率で陥るだろうと思われるエラー。透過 png のグラデーションを使用した場合に起きる。
実際このエラーではまってました。
「俺の作ったpngデータが間違っているはずがない!!」などとずっとがんばってましたが,検索で先に調べるべきでした。



Progression URLObject の使い道

2009 年 7 月 13 日 コメントはありません
Progression URLObject ってデータベースのやりとりに便利?な予感。AIRとか。
その他にもURL指定してあげれば

url.navigateTo("_blank");

navigateToURLみたいに使えます。


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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package {
    import flash.display.Sprite;
    import jp.nium.net.*;
    import flash.text.*;
    import jp.nium.external.*;
 
 
    public class FlashTest extends Sprite {
        private var textList:Array =[];
 
        public function FlashTest() {
 
            var url:URLObject = new URLObject("http://asdoc.progression.jp/test.swf");
            var url2:URLObject = new URLObject("http://localhost:8081/yaimo");
 
            url.password = "password";
            url.user = "me";
            textinit();
 
            textList[0].text = url.toString();
            textList[1].text = url.host;
            textList[2].text = url.password;
            textList[3].text = url.url;
            textList[4].text = url.fileExtension;
            textList[5].text = ""+URLObject.validate("URLOBjectととはなんぞや");
            textList[6].text = url.fileName;
            textList[7].text = url2.port;
            textList[8].text = url.user;
 
            //URLRequestでかえってくるのでとりあえずURLはURLObjectに入れとけば管理しやすいとか?
            textList[9].text = url.toURLRequest();
 
            //Flash Player のコンテナを含むアプリケーション(通常はブラウザ)でウィンドウを開くか、置き換えます。
            //コメントをはずすと指定URLに飛びます。
            //user設定してあるとuserでログインしたりもできる。
            //url.navigateTo("_blank");
 
            //あとはデータベースと連動するときに役に立ちそうな予感(AIRとか)
            //指定URLに飛んだりするのが便利だった!!
 
        }
        public function textinit():void{
            for(var i:int = 0; i<10;i++){
                var text:TextField = new TextField();
                text.width = 300;
                text.y = i*20;
                addChild(text);
                textList.push(text);
                }
            }
    }
}