<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>almondlab. &#187; FLASH</title>
	<atom:link href="http://www.almondlab.jp/tag/flash/feed" rel="self" type="application/rss+xml" />
	<link>http://www.almondlab.jp</link>
	<description>Web Design, Graphic Design, FLASH, CMS</description>
	<lastBuildDate>Sat, 28 Jan 2012 15:25:03 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ActionScriptで透過ビットマップのロールオーバーを判定。</title>
		<link>http://www.almondlab.jp/labs/890</link>
		<comments>http://www.almondlab.jp/labs/890#comments</comments>
		<pubDate>Wed, 15 Jun 2011 05:54:11 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[labs]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=890</guid>
		<description><![CDATA[マウスのロールオーバー時に、ビットマップの透過ではない部分でのみ判定をする方法です。]]></description>
			<content:encoded><![CDATA[<p>マウスのロールオーバー時に、ビットマップの透過ではない部分でのみ判定をする方法です。<br />
通常ビットマップのマウス判定には矩形エリア全体が対象になるので、透明PNGの透明部分でも判定されてしまいます。<br />
それを回避する方法として、マウスのイベントリスナーを使うのではなく、マウス座標上にあるビットマップのピクセル色が透明かどうかを測定して、判定をするようにしています。<br />
<span class="link"><a href="http://www.almondlab.jp/wp-content/uploads/bitmap-rollover">サンプルはこちら</a></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Bitmap</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PixelSnapping</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//ライブラリ内の「Cloud」ビットマップクラス（透過PNG）インスタンスを作成</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> bitmap_data<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Cloud<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> bitmap<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span>bitmap_data<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">PixelSnapping</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NEVER</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bitmap<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			setBitmapRollOverOut<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">,</span> bitmap_data<span style="color: #000066; font-weight: bold;">,</span> targetOverTest<span style="color: #000066; font-weight: bold;">,</span> targetOutTest<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//ロールオーバー時</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> targetOverTest<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">:*</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">buttonMode</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//ロールアウト時</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> targetOutTest<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">:*</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">buttonMode</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//引数にロールオーバー時、ロールアウト時の関数を渡します</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> setBitmapRollOverOut<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000066; font-weight: bold;">,</span> bitmap_data<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">,</span> rolloverFunction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span><span style="color: #000066; font-weight: bold;">,</span> rolloutFunction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> targetOverEnter<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #339966; font-weight: bold;">function</span> targetOverEnter<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//マウス位置のビットマップの（アルファ値を含む）ピクセル色を測定</span>
				<span style="color: #004993;">color</span> = bitmap_data<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getPixel32</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//ビットマップが透明でなければロールオーバー関数を実行</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span> <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
					<span style="color: #009900; font-style: italic;">//ロールオーバー関数の実行を一度だけにするため、一旦エンターフレームを解除します</span>
					<span style="color: #009900; font-style: italic;">//同時にロールアウトのエンターフレームを再開します</span>
					<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> targetOverEnter<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> targetOutEnter<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					rolloverFunction<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #339966; font-weight: bold;">function</span> targetOutEnter<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//マウス位置のビットマップの（アルファ値を含む）ピクセル色を測定</span>
				<span style="color: #004993;">color</span> = bitmap_data<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getPixel32</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//ビットマップが透明だったらロールアウト関数を実行</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span> == <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
					<span style="color: #009900; font-style: italic;">//ロールアウト関数の実行を一度だけにするため、一旦エンターフレームを解除します</span>
					<span style="color: #009900; font-style: italic;">//同時にロールオーバーのエンターフレームを再開します</span>
					<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> targetOverEnter<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> targetOutEnter<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					rolloutFunction<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/labs/890/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScriptでXMLを操作するときのメモ。</title>
		<link>http://www.almondlab.jp/notes/833</link>
		<comments>http://www.almondlab.jp/notes/833#comments</comments>
		<pubDate>Tue, 29 Mar 2011 07:35:38 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=833</guid>
		<description><![CDATA[ActionScriotでXMLを操作する際に、よく使うメソッドのメモです。]]></description>
			<content:encoded><![CDATA[<p>ActionScriotでXMLを操作する際に、よく使うメソッドのメモです。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> =
<span style="color: #000066; font-weight: bold;">&lt;</span>root<span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;</span>item id=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
		<span style="color: #000066; font-weight: bold;">&lt;</span>name<span style="color: #000066; font-weight: bold;">&gt;</span>test1<span style="color: #000066; font-weight: bold;">&lt;/</span>name<span style="color: #000066; font-weight: bold;">&gt;</span>
		<span style="color: #000066; font-weight: bold;">&lt;</span>url<span style="color: #000066; font-weight: bold;">&gt;</span>www<span style="color: #000066; font-weight: bold;">.</span>example1<span style="color: #000066; font-weight: bold;">.</span>com<span style="color: #000066; font-weight: bold;">&lt;/</span>url<span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;/</span>item<span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;</span>item id=<span style="color: #990000;">&quot;2&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
		<span style="color: #000066; font-weight: bold;">&lt;</span>name<span style="color: #000066; font-weight: bold;">&gt;</span>test2<span style="color: #000066; font-weight: bold;">&lt;/</span>name<span style="color: #000066; font-weight: bold;">&gt;</span>
		<span style="color: #000066; font-weight: bold;">&lt;</span>url<span style="color: #000066; font-weight: bold;">&gt;</span>www<span style="color: #000066; font-weight: bold;">.</span>example2<span style="color: #000066; font-weight: bold;">.</span>com<span style="color: #000066; font-weight: bold;">&lt;/</span>url<span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;/</span>item<span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;</span>item id=<span style="color: #990000;">&quot;3&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
		<span style="color: #000066; font-weight: bold;">&lt;</span>name<span style="color: #000066; font-weight: bold;">&gt;</span>test3<span style="color: #000066; font-weight: bold;">&lt;/</span>name<span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;/</span>item<span style="color: #000066; font-weight: bold;">&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;/</span>root<span style="color: #000066; font-weight: bold;">&gt;;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//一つ目（0番目）の「item」ノード内の「name」ノードの内容を取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">//test1</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//二つ目の「item」ノードの「id」属性を取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">child</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;item&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>@id<span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">//2</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//「item」ノードの数を取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//3</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//「item」ノード内の「url」ノードの数を取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000066; font-weight: bold;">..</span><span style="color: #004993;">url</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//2</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//一つ目（0番目）の「item」ノードの二つ目（1番目）のノード名を取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">child</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//url</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//「item」ノード内の「name」ノードの内容が「test1」の「url」ノードの内容を取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000066; font-weight: bold;">.</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span> == <span style="color: #990000;">&quot;test1&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//www.example1.com</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//「item」ノード内の「id」属性が「2」の「url」ノードの内容を取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000066; font-weight: bold;">.</span><span style="color: #000000;">&#40;</span>@id == <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span><span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">//www.example2.com</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//三つ目（2番目）の「item」ノードに「url」ノードの有無をブール値で取得</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;url&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//false</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/833/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flashプレーヤーでバージョン関連の参考ページ。</title>
		<link>http://www.almondlab.jp/notes/794</link>
		<comments>http://www.almondlab.jp/notes/794#comments</comments>
		<pubDate>Tue, 01 Feb 2011 06:04:30 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=794</guid>
		<description><![CDATA[Flashプレイヤーでバージョンにおける参考ページいくつか。]]></description>
			<content:encoded><![CDATA[<p>Flashプレイヤーの普及率は高く、バージョンにおける問題はそれほど発生することがありません。今ではバージョン10を対象にした制作が主流です。<br />
ですが、ごく稀に旧バージョン対応コンテンツを制作の場合には、下記のページが参考になります。</p>
<div class="space"></div>
<dl>
<dt><a href="http://www.adobe.com/products/player_census/flashplayer/version_penetration.html" onclick="window.open(this.href); return false;">Flashプレイヤーの普及率</a></dt>
<dd>バージョン別、地域別でFlashプレイヤーの普及率を見ることができます。世界と比べると日本での普及率は、やや低いですね。</dd>
<dt><a href="http://www.adobe.com/jp/software/flash/about/" onclick="window.open(this.href); return false;">Flashプレイヤーのバージョンチェック</a></dt>
<dd>ブラウザにインストールしてあるFlashプレイヤーのバージョンを確認できます。（あまり目立たない位置にありますが）</dd>
<dt><a href="http://www.adobe.com/jp/shockwave/download/alternates/#fp" onclick="window.open(this.href); return false;">Flashプレイヤーアンインストーラ</a></dt>
<dd>Flashプレイヤーのアンインストーラが各OSごとに用意されています。旧バージョンをインストールする場合に、予めアンインストールする必要があります。</dd>
<dt><a href="http://kb2.adobe.com/cps/142/tn_14266.html" onclick="window.open(this.href); return false;">Flashプレイヤー旧バージョン</a></dt>
<dd>開発用途で旧バージョンのFlashプレイヤーが配布されています。</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/794/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScriptで年月日を取得。</title>
		<link>http://www.almondlab.jp/notes/776</link>
		<comments>http://www.almondlab.jp/notes/776#comments</comments>
		<pubDate>Sun, 09 Jan 2011 03:56:15 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=776</guid>
		<description><![CDATA[ActionScriptで年月日を取得して表示する際のメモです。]]></description>
			<content:encoded><![CDATA[<p>ActionScriptで年月日を取得して表示する際のメモです。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">date</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Date</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> days<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> today<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
days = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;sun&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;mon&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;tue&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;wed&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;thu&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;fri&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;sat&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
today = <span style="color: #004993;">date</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fullYear</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;/&quot;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">date</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">month</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;/&quot;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">date</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">date</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;(&quot;</span><span style="color: #000066; font-weight: bold;">+</span>days<span style="color: #000000;">&#91;</span><span style="color: #004993;">date</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">day</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;)&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>today<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//2011/1/9(sun)</span></pre></td></tr></table></div>

<p>月は0（1月）から11（12月）で、曜日は0（日曜日）から6（土曜日）の値を返します。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/776/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>外部SWFファイルからフォントの埋め込み。</title>
		<link>http://www.almondlab.jp/labs/758</link>
		<comments>http://www.almondlab.jp/labs/758#comments</comments>
		<pubDate>Sun, 02 Jan 2011 03:56:25 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[labs]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[Font]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=758</guid>
		<description><![CDATA[ActionScriptで外部のSWFファイルに登録してあるフォントを、動的に埋め込む方法です。]]></description>
			<content:encoded><![CDATA[<p>ActionScriptで外部のSWFファイルに登録してあるフォントを、動的に埋め込む方法です。<br />
初めにフォント情報をリンケージとして登録するためのSWFを作成します。<br />
新規でflaファイルを作成して、ライブラリパネル上で右クリックから表示されるコンテクストメニューで「新しいフォント…」を選択します。<br />
<img src="http://www.almondlab.jp/wp-content/uploads/font-embed-01.png" alt="" title="" width="931" height="546" class="space" /><br />
フォント名を入力して、埋め込みたいフォントと文字を選択します。<br />
ここでのフォント名は後から参照することはないので、自由な名称で構いません。<br />
<img src="http://www.almondlab.jp/wp-content/uploads/font-embed-02.png" alt="" title="" width="931" height="546" class="space" /><br />
続いて「ActionScript」タブからリンケージの「アクションスクリプト用に書き出し」にチェックを入れて、クラス名を入力します。<br />
このクラス名は埋め込みの際にActionScriptから参照します。<br />
<img src="http://www.almondlab.jp/wp-content/uploads/font-embed-03.png" alt="" title="" width="269" height="337" class="space" /><br />
これでライブラリパネルに、リンケージとしてフォントが登録されました。<br />
この状態でSWFファイルを書き出して、ファイル名を「fonts.swf」としておきます。</p>
<div class="space"></div>
<p>次に、作成した外部SWFを読み込み、フォントを埋め込むActionScriptファイルを作成します。<br />
下記のようなスクリプトを記述します。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Loader</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span>	
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.system</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ApplicationDomain</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextField</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextFormat</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onComplete<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;fonts.swf&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #339966; font-weight: bold;">function</span> onComplete<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">domain</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">ApplicationDomain</span> = <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">applicationDomain</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> HelveticaRegular<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span> = <span style="color: #004993;">domain</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getDefinition</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;HelveticaRegular&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> field<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> format<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextFormat</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextFormat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> helvetica_regular<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Font</span> = <span style="color: #0033ff; font-weight: bold;">new</span> HelveticaRegular<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>HelveticaRegular<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				format<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">font</span> = helvetica_regular<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fontName</span><span style="color: #000066; font-weight: bold;">;</span>
				field<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">defaultTextFormat</span> = format<span style="color: #000066; font-weight: bold;">;</span>
				field<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
				field<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">antiAliasType</span> = <span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADVANCED</span><span style="color: #000066; font-weight: bold;">;</span>
				field<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Font embedded via external swf file.&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>field<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>上記はドキュメントクラスとして記述した場合の例です。</p>
<div class="space"></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
17
18
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onComplete<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;fonts.swf&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>初めに作成した外部SWFファイルを読み込みます。</p>
<div class="space"></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>21
22
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">domain</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">ApplicationDomain</span> = <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">applicationDomain</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> HelveticaRegular<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span> = <span style="color: #004993;">domain</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getDefinition</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;HelveticaRegular&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>外部SWFファイルにリンケージとして登録したフォント（クラス）を利用可能にするために「ApplicationDomain」を登録します。<br />
フォントクラス「HelveticaRegular」として登録します。</p>
<div class="space"></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>26
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">Font</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>HelveticaRegular<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>先ほど登録したフォントクラスを、グローバルフォントに登録します。</p>
<div class="space"></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>27
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">format<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">font</span> = helvetica_regular<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fontName</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>フォントクラスから作成したオブジェクトをもとに、テキストフォーマットにフォント名を指定します。</p>
<div class="space"></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>29
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">field<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>フォントの埋め込みを有効にします。</p>
<div class="space"></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>30
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">field<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">antiAliasType</span> = <span style="color: #004993;">AntiAliasType</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADVANCED</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>フォントクラスから埋め込みの際のテキストフィールドは、アンチエイリアスが「NORMAL」の状態で、あまりきれいではないので「ADVANCED」に変更します。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/labs/758/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>オブジェクト、配列の反復処理。</title>
		<link>http://www.almondlab.jp/notes/652</link>
		<comments>http://www.almondlab.jp/notes/652#comments</comments>
		<pubDate>Sat, 29 May 2010 02:24:22 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=652</guid>
		<description><![CDATA[ActionScriptでオブジェクト、または配列の要素を繰り返し処理のメモです。]]></description>
			<content:encoded><![CDATA[<p>ActionScriptでオブジェクト、または配列の要素を繰り返し処理のメモです。<br />
繰り返しの処理にはfor-in文、for each-in文があります。それぞれの違いは生成する要素が、for-in文ではキーを生成して、for each-in文では値を生成します。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> object<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
object<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;りんご&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
object<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;ばなな&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
object<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;integer&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
object<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;array&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">new</span>  <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;test1&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;test2&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//キーを生成</span>
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> key<span style="color: #000066; font-weight: bold;">:*</span> <span style="color: #0033ff; font-weight: bold;">in</span> object<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>key<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//値を生成</span>
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:*</span> <span style="color: #0033ff; font-weight: bold;">in</span> object<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>それぞれの出力は次のようになります。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//for-inの場合</span>
<span style="color: #000000; font-weight:bold;">0</span>
<span style="color: #000000; font-weight:bold;">1</span>
array
integer
&nbsp;
<span style="color: #009900; font-style: italic;">//for each-inの場合</span>
りんご
ばなな
test1<span style="color: #000066; font-weight: bold;">,</span>test2
<span style="color: #000000; font-weight:bold;">10</span></pre></td></tr></table></div>

<p>キーと値の両方を扱いたい場合には、for-in文でキーを生成して、キーから値を呼び出します。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> key<span style="color: #000066; font-weight: bold;">:*</span> <span style="color: #0033ff; font-weight: bold;">in</span> object<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>key<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>object<span style="color: #000000;">&#91;</span>key<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/652/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScriptでフルスクリーン表示のメモ。</title>
		<link>http://www.almondlab.jp/notes/589</link>
		<comments>http://www.almondlab.jp/notes/589#comments</comments>
		<pubDate>Sat, 15 May 2010 06:10:48 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=589</guid>
		<description><![CDATA[ActionScriptでフルスクリーン表示のためのスクリプトのメモです。]]></description>
			<content:encoded><![CDATA[<p>ActionScriptでフルスクリーン表示のためのスクリプトのメモです。<br />
ステージの原点と左上にして、ウィンドウサイズの変化による拡大縮小は無効の設定です。<br />
ウィンドウ（ステージ）がリサイズされた際に「resizeWindow」を実行します。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NO_SCALE</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TOP_LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">RESIZE</span><span style="color: #000066; font-weight: bold;">,</span> resizeWindow<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> resizeWindow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">//ウィンドウがリサイズされた際の処理</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/589/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScriptでイメージのスライス。</title>
		<link>http://www.almondlab.jp/labs/499</link>
		<comments>http://www.almondlab.jp/labs/499#comments</comments>
		<pubDate>Sun, 28 Feb 2010 15:00:17 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[labs]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=499</guid>
		<description><![CDATA[ActionScriptで読み込んだ一枚の画像を、グリッド状にスライスする方法です。]]></description>
			<content:encoded><![CDATA[<p>ActionScriptで読み込んだ一枚の画像を、グリッド状にスライスする方法です。<br />
<span class="link"><a href="http://www.almondlab.jp/wp-content/uploads/bitmap-slice" onclick="window.open(this.href); return false;">サンプルはこちら</a></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Bitmap</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Loader</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LoaderInfo</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PixelSnapping</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Rectangle</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span>	
	<span style="color: #0033ff; font-weight: bold;">import</span> caurina<span style="color: #000066; font-weight: bold;">.</span>transitions<span style="color: #000066; font-weight: bold;">.</span>Tweener<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> caurina<span style="color: #000066; font-weight: bold;">.</span>transitions<span style="color: #000066; font-weight: bold;">.</span>properties<span style="color: #000066; font-weight: bold;">.</span>DisplayShortcuts<span style="color: #000066; font-weight: bold;">;</span>  
	DisplayShortcuts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>  
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;800&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;600&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;30&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;0xffffff&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//スライス元のイメージを読み込み</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">LoaderInfo</span> = <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onLoaded<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;image.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//読み込みが完了したとき</span>
			<span style="color: #339966; font-weight: bold;">function</span> onLoaded<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> bmd_base<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> param<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				bmd_base<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">loader</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//X軸・Y軸の分割数と、ピースの横幅・縦幅</span>
				param<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span>
				param<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span>
				param<span style="color: #000066; font-weight: bold;">.</span>w = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span>
				param<span style="color: #000066; font-weight: bold;">.</span>h = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//Y軸のループ</span>
				<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> param<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
					<span style="color: #009900; font-style: italic;">//X軸のループ</span>
					<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> j <span style="color: #000066; font-weight: bold;">&lt;</span> param<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						<span style="color: #6699cc; font-weight: bold;">var</span> place<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">rect</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span>param<span style="color: #000066; font-weight: bold;">.</span>w<span style="color: #000066; font-weight: bold;">*</span>j<span style="color: #000066; font-weight: bold;">,</span> param<span style="color: #000066; font-weight: bold;">.</span>h<span style="color: #000066; font-weight: bold;">*</span>i<span style="color: #000066; font-weight: bold;">,</span> param<span style="color: #000066; font-weight: bold;">.</span>w<span style="color: #000066; font-weight: bold;">,</span> param<span style="color: #000066; font-weight: bold;">.</span>h<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						<span style="color: #6699cc; font-weight: bold;">var</span> bmd<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>param<span style="color: #000066; font-weight: bold;">.</span>w<span style="color: #000066; font-weight: bold;">,</span> param<span style="color: #000066; font-weight: bold;">.</span>h<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						<span style="color: #6699cc; font-weight: bold;">var</span> bm<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
						<span style="color: #009900; font-style: italic;">//元のイメージから切り抜き</span>
						bmd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copyPixels</span><span style="color: #000000;">&#40;</span>bmd_base<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">rect</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span> = bmd<span style="color: #000066; font-weight: bold;">;</span>
						bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pixelSnapping</span> = <span style="color: #004993;">PixelSnapping</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NEVER</span><span style="color: #000066; font-weight: bold;">;</span>
						bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">smoothing</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
						<span style="color: #009900; font-style: italic;">//ピースの原点を左上から中心に移動</span>
						bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000066; font-weight: bold;">-</span>param<span style="color: #000066; font-weight: bold;">.</span>w<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
						bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000066; font-weight: bold;">-</span>param<span style="color: #000066; font-weight: bold;">.</span>h<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
						place<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = param<span style="color: #000066; font-weight: bold;">.</span>w<span style="color: #000066; font-weight: bold;">*</span>j<span style="color: #000066; font-weight: bold;">+</span>param<span style="color: #000066; font-weight: bold;">.</span>w<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
						place<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = param<span style="color: #000066; font-weight: bold;">.</span>h<span style="color: #000066; font-weight: bold;">*</span>i<span style="color: #000066; font-weight: bold;">+</span>param<span style="color: #000066; font-weight: bold;">.</span>h<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
						place<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bm<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>place<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
						<span style="color: #009900; font-style: italic;">//透明度、スケールを、それぞれ0から100％にアニメーション</span>
						Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>place<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">alpha</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> _scale<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>place<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">delay</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>param<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">*</span>i<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span>j<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">time</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">alpha</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> _scale<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><span class="caption">photo by : chantrybee</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/labs/499/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweenerでテキストを一文字ずつ表示。</title>
		<link>http://www.almondlab.jp/notes/432</link>
		<comments>http://www.almondlab.jp/notes/432#comments</comments>
		<pubDate>Sun, 21 Feb 2010 11:42:08 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=432</guid>
		<description><![CDATA[ActionScriptのライブラリ「Tweener」を使って、テキストを一文字ずつ表示する方法です。]]></description>
			<content:encoded><![CDATA[<p>ActionScriptのライブラリ「<a href="http://hosted.zeh.com.br/tweener/docs/en-us/" onclick="window.open(this.href); return false;">Tweener</a>」を使って、テキストを一文字ずつ表示する方法です。<br />
<span class="link"><a href="http://www.almondlab.jp/wp-content/uploads/tweener-text" onclick="window.open(this.href); return false;">サンプルはこちら</a></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> caurina<span style="color: #000066; font-weight: bold;">.</span>transitions<span style="color: #000066; font-weight: bold;">.</span>Tweener<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> caurina<span style="color: #000066; font-weight: bold;">.</span>transitions<span style="color: #000066; font-weight: bold;">.</span>properties<span style="color: #000066; font-weight: bold;">.</span>TextShortcuts<span style="color: #000066; font-weight: bold;">;</span>  
	TextShortcuts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//テキストショートカットを初期化</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> types<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;Tweenerを利用すると、簡単にテキストを一文字ずつ表示することができます。&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//2秒間でtypesのテキストを一文字ずつ表示</span>
			Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>text_field<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">time</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> _text<span style="color: #000066; font-weight: bold;">:</span>types<span style="color: #000066; font-weight: bold;">,</span> transition<span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;linear&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><span class="link"><a href="http://hosted.zeh.com.br/tweener/docs/en-us/" onclick="window.open(this.href); return false;">Tweener Documentation</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/432/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScriptからPHPの関数を実行。</title>
		<link>http://www.almondlab.jp/labs/380</link>
		<comments>http://www.almondlab.jp/labs/380#comments</comments>
		<pubDate>Sat, 06 Feb 2010 15:00:29 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[labs]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=380</guid>
		<description><![CDATA[WEBページのFLASHから、任意のPHP関数を呼び出す方法です。]]></description>
			<content:encoded><![CDATA[<p>ActionScriptからPHPを実行するには、「URLLoader」を使ってPHPファイルにアクセスすることができます。その際に引数を渡すには「URLVariables」でGET、またはPOSTの変数を渡すことができます。<br />
この方法では、アクセスするPHPファイル全体を実行します。</p>
<div class="space"></div>
<p>PHPファイル内の任意の関数のみを実行するには、ActionScriptからGET、またはPOSTの変数を経由し、PHPの関数名の文字列を変数で渡して、PHP側で文字列を関数名として評価することで任意の関数を実行できます。</p>
<div class="space"></div>
<p>ActionScriptでは、次のように記述します。（ドキュメントクラスに書いています）</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLLoader</span><span style="color: #000066; font-weight: bold;">;</span>	
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span>	
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLRequestMethod</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLVariables</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TextField</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> url_variables<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLVariables</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLVariables</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> url_request<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;functions.php&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//PHPリクエストのPOST変数にPHPの関数名を含める</span>
			url_variables<span style="color: #000066; font-weight: bold;">.</span>function_name = <span style="color: #990000;">&quot;test&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
			url_request<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">method</span> = <span style="color: #004993;">URLRequestMethod</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">POST</span><span style="color: #000066; font-weight: bold;">;</span>
			url_request<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> = url_variables<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//PHPを実行（読み込み）</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onComplete<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>url_request<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//PHPの実行が完了したとき</span>
			<span style="color: #339966; font-weight: bold;">function</span> onComplete<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//テキストフィールドを作成して、PHP関数の出力を表示</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> textfield<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>textfield<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				textfield<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>PHPファイル「functions.php」にPOST変数で関数名「function_name」を文字列で渡します。PHPファイルの読み込み（実行）が完了したら「onCimplete」にて、PHPで出力された文字列「event.target.data」を扱えるようになります。</p>
<div class="space"></div>
<p>PHPファイル「functions.php」には、次のように記述します。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//POST変数「function_name」の関数が存在したら実行</span>
<span style="color: #000088;">$function</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'function_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$function</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//文字列を出力（ActionScriptに渡す）</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;function test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>「$function」にPOST変数の「function_name」を代入して、同名の関数が存在していたら実行します。<br />
PHPから出力された文字列は、そのままActionScriptで受け取ることができます。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/labs/380/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ボタンのロールオーバー、ロールアウト、クリックの設定。</title>
		<link>http://www.almondlab.jp/notes/274</link>
		<comments>http://www.almondlab.jp/notes/274#comments</comments>
		<pubDate>Thu, 14 Jan 2010 15:00:14 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=274</guid>
		<description><![CDATA[ボタンオブジェクトに対して、ロールオーバー、ロールアウト、クリックをまとめて設定するスクリプトです。]]></description>
			<content:encoded><![CDATA[<p>ボタンオブジェクトに対して、ロールオーバー、ロールアウト、クリックをまとめて設定するスクリプトです。<br />
ロールオーバー、ロールアウト、クリックのイベントリスナーごと、関数内に記述して、内包しているリスナーの関数を実行しています。リスナーの関数は一つだけ書いて、イベントタイプの文字列で振り分けるようにしています。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">setButton<span style="color: #000000;">&#40;</span>button<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;test&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//ボタンにロールオーバー、ロールアウト、クリックの設定</span>
<span style="color: #339966; font-weight: bold;">function</span> setButton<span style="color: #000000;">&#40;</span>button<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">DisplayObject</span><span style="color: #000066; font-weight: bold;">,</span> str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	button<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ROLL_OVER</span><span style="color: #000066; font-weight: bold;">,</span> mouseEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	button<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ROLL_OUT</span><span style="color: #000066; font-weight: bold;">,</span> mouseEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	button<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> mouseEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//イベントのタイプで処理を振り分け</span>
	<span style="color: #339966; font-weight: bold;">function</span> mouseEvent<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">type</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;rollOver&quot;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #009900; font-style: italic;">//ロールオーバーのとき</span>
				button<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;over&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;rollOut&quot;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #009900; font-style: italic;">//ロールアウトのとき</span>
				button<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;out&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;click&quot;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #009900; font-style: italic;">//クリックのとき</span>
				button<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;click&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/274/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>イベントリスナーで引数を渡す方法。</title>
		<link>http://www.almondlab.jp/notes/264</link>
		<comments>http://www.almondlab.jp/notes/264#comments</comments>
		<pubDate>Wed, 13 Jan 2010 11:45:25 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=264</guid>
		<description><![CDATA[マウスのクリック時などのイベントリスナーで、追加の引数を渡す方法です。]]></description>
			<content:encoded><![CDATA[<p>マウスのクリック時などのイベントリスナーで、追加の引数を渡す方法です。<br />
通常イベントリスナーから呼び出すリスナーの関数には引数を渡すことができませんが、次の方法で任意に渡すことができます。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> mouseClick<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;test&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> mouseClick<span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//クリックされたときの処理</span>
		<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>str<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>イベントリスナーから呼び出す関数の戻り値に、イベントオブジェクトを引数とする関数を返すことで、引数を受け取ることが可能になります。<br />
上記のスクリプトでは無名関数にしているので少し読みづらいですが、書き換えると次のようになります。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> mouseClick<span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> mouseEvent<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #339966; font-weight: bold;">function</span> mouseEvent<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//クリックされたときの処理</span>
		<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>str<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/264/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScriptで配列のシャッフル。</title>
		<link>http://www.almondlab.jp/notes/258</link>
		<comments>http://www.almondlab.jp/notes/258#comments</comments>
		<pubDate>Mon, 11 Jan 2010 15:20:41 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=258</guid>
		<description><![CDATA[配列の順番をランダムにソートしてシャッフルを行うスクリプトです。]]></description>
			<content:encoded><![CDATA[<p>配列の順番をランダムにソートしてシャッフルを行うスクリプトです。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> array_01<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">9</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> array_02<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = array_01<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">slice</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//array_01を複製</span>
&nbsp;
shuffleArray<span style="color: #000000;">&#40;</span>array_02<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//シャッフルを実行</span>
&nbsp;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>array_01<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//1,2,3,4,5,6,7,8,9,10</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>array_02<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//3,2,10,4,6,8,1,7,9,5</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//配列をランダムにソートしてシャッフル</span>
<span style="color: #339966; font-weight: bold;">function</span> shuffleArray<span style="color: #000000;">&#40;</span>array<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	array<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sort</span><span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/258/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ウィンドウ内をスクロールするフィールド。</title>
		<link>http://www.almondlab.jp/labs/242</link>
		<comments>http://www.almondlab.jp/labs/242#comments</comments>
		<pubDate>Sun, 10 Jan 2010 15:00:47 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[labs]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=242</guid>
		<description><![CDATA[縦横に複数のページを持つフィールドを、ウィンドウ内でスクロールします。]]></description>
			<content:encoded><![CDATA[<p>縦横に複数のページを持つフィールドを、ウィンドウ内でスクロールします。グリッド状に縦横にページを作成して、方向キーの操作でページをスクロールします。<br />
<span class="link"><a onclick="window.open(this.href); return false;"  href="http://www.almondlab.jp/wp-content/uploads/scroll-field/">サンプルはこちら</a></span><br />
（方向キーを有効にするには、一度FLASHエリアをクリックして、フォーカスを当てる必要があります）</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Shape</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Rectangle</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> caurina<span style="color: #000066; font-weight: bold;">.</span>transitions<span style="color: #000066; font-weight: bold;">.</span>Tweener<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> piece<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">800</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">600</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//ページのサイズ</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> current<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//フィールド内のページ位置</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> pivot<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//ステージの中心点</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> field<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			pivot<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>field<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>pivot<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			setPivot<span style="color: #000000;">&#40;</span>pivot<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//ステージのスケールを固定で、原点を左上に</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NO_SCALE</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TOP_LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//横15×縦10のページでフィールドを作成</span>
			makeField<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">15</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//フィールドを作成</span>
			<span style="color: #339966; font-weight: bold;">function</span> makeField<span style="color: #000000;">&#40;</span>grid<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> grid<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> j <span style="color: #000066; font-weight: bold;">&lt;</span> grid<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
						<span style="color: #009900; font-style: italic;">//ページに矩形を描きランダムに彩色</span>
						<span style="color: #6699cc; font-weight: bold;">var</span> shape<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Shape</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Shape</span><span style="color: #000066; font-weight: bold;">;</span>
						shape<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">*</span>j<span style="color: #000066; font-weight: bold;">-</span>piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
						shape<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">*</span>i<span style="color: #000066; font-weight: bold;">-</span>piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
						shape<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span>0x1000000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						shape<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span>piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						shape<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						field<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>shape<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
				<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">KEY_DOWN</span><span style="color: #000066; font-weight: bold;">,</span> onKeyPress<span style="color: #000000;">&#40;</span>grid<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//方向キーでスクロールの設定</span>
			<span style="color: #339966; font-weight: bold;">function</span> onKeyPress<span style="color: #000000;">&#40;</span>grid<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span><span style="color: #000066; font-weight: bold;">:</span> current<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">--;</span> <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//左キー</span>
						<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span><span style="color: #000066; font-weight: bold;">:</span> current<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">--;</span> <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//上キー</span>
						<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span><span style="color: #000066; font-weight: bold;">:</span> current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">++;</span> <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//右キー</span>
						<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span><span style="color: #000066; font-weight: bold;">:</span> current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">++;</span> <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//下キー</span>
					<span style="color: #000000;">&#125;</span>
&nbsp;
					<span style="color: #009900; font-style: italic;">//フィールドの端まで移動したとき</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= grid<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = grid<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= grid<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = grid<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
					Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>field<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">time</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.75</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:-</span>piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">*</span>current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:-</span>piece<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">*</span>current<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//ステージサイズに合わせて中心点を移動</span>
			<span style="color: #339966; font-weight: bold;">function</span> setPivot<span style="color: #000000;">&#40;</span>pivot<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">RESIZE</span><span style="color: #000066; font-weight: bold;">,</span> transfield<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				transfield<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #339966; font-weight: bold;">function</span> transfield<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
					Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>pivot<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">time</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.75</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageHeight</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/labs/242/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ブラウザ上でActionSctiptの簡易デバッグ。</title>
		<link>http://www.almondlab.jp/labs/146</link>
		<comments>http://www.almondlab.jp/labs/146#comments</comments>
		<pubDate>Thu, 07 Jan 2010 14:50:27 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[labs]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=146</guid>
		<description><![CDATA[ブラウザでFLASHを再生中、デバッグのためにパラメータなどを出力する方法です。]]></description>
			<content:encoded><![CDATA[<p>ブラウザでFLASHを再生中、デバッグのためにパラメータなどを出力する方法です。<br />
ActionScriptを制作中によく利用するtraceですが、ブラウザで再生中には実行することができません。そこでJavaScriptとの連携を利用して同様のことを実現します。<br />
はじめにHTML内にJavaScriptで、引数を受け取りダイアログで表示するスクリプトを記述します。関数名は「flashTrace」としておきます。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> flashTrace<span style="color: #009900;">&#40;</span>$str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>$str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>次にActionScriptでは、JavaScriptの関数を実行するたスクリプトを記述します。引数の一つ目がJavaScriptの関数名で、二つ目が出力したいパラメータです。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">ExternalInterface</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;flashTrace&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;デバッグのテスト&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>これでブラウザで再生中に、ダイアログでActionScript内のパラメータを出力することができます。<br />
ですが、このままだとFLASHで制作中のときには、traceも併記する必要が出てしまいます。その場合、下記のようにブラウザで再生かどうかを判定して、どちらか実行する関数にしておくと便利です。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">ft<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;デバッグのテスト&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> ft<span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//サーバへのアクセスを判定してJavascript、またはtraceを実行</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">loaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http&quot;</span><span style="color: #000000;">&#41;</span> == <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #004993;">ExternalInterface</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;flashTrace&quot;</span><span style="color: #000066; font-weight: bold;">,</span> str<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>str<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>ちなみにサーバへのアクセス（http://）ではなく、ブラウザで直接HTMLファイルを開いた場合（file://）には、FLASHのセキュリティでJavaScriptが実行されません。外部サーバではなくローカルで実行するには、Webサーバをローカル環境に構築する必要があります。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/labs/146/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQueryのプラグインでFLASHの埋め込み。</title>
		<link>http://www.almondlab.jp/notes/119</link>
		<comments>http://www.almondlab.jp/notes/119#comments</comments>
		<pubDate>Tue, 05 Jan 2010 02:04:08 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[notes]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=119</guid>
		<description><![CDATA[jQueryのプラグインを利用して、HTMLにFLASHを簡単に埋め込む方法です。]]></description>
			<content:encoded><![CDATA[<p>jQueryのプラグインを利用して、HTMLにFLASHを簡単に埋め込む方法です。短いコードで記述できるので、ソースコードがすっきりとして見やすくなります。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>jQuery FLASH<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.3.2.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.flash.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
&nbsp;
$(document).ready(function() {
$('div#flash').flash({'src':'main.swf', 'width':'800', 'height':'400'});
});
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flash&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>このページのコンテンツには、Adobe Flash Playerの最新バージョンが必要です。<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!-- flash --&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>&lt;head&gt;タグ内にjQuery本体と<a href="http://plugins.jquery.com/project/jquery_flash" onclick="window.open(this.href); return false;">jquery.flash.js</a>を読み込んで、div#flashに対して埋め込みの記述をします。<br />
最低限必要なのはSWFファイルのパスのみで、width、heightは省略できます。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.3.2.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.flash.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
&nbsp;
$(document).ready(function() {
$('div#flash').flash({'src':'main.swf', 'width':'800', 'height':'400'});
});
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p>FLASHにパラメータを渡す場合は、次のようにflashvarsをオブジェクトで追加します。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>10
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">$('div#flash').flash({'src':'main.swf', 'width':'800', 'height':'400', 'flashvars':{'init':'init.xml', 'image':'image.jpg'}});</pre></td></tr></table></div>

<p><span class="link"><a href="http://plugins.jquery.com/project/jquery_flash" onclick="window.open(this.href); return false;">jquery.flash.jsプラグインページ</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/notes/119/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FLASHでビットマップのフルスクリーン表示。</title>
		<link>http://www.almondlab.jp/labs/43</link>
		<comments>http://www.almondlab.jp/labs/43#comments</comments>
		<pubDate>Fri, 01 Jan 2010 17:03:30 +0000</pubDate>
		<dc:creator>almondlab.</dc:creator>
				<category><![CDATA[labs]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLASH]]></category>

		<guid isPermaLink="false">http://www.almondlab.jp/?p=43</guid>
		<description><![CDATA[外部ビットマップデータを読み込んで、ウィンドウ全面に表示されるように拡大・縮小を行います。]]></description>
			<content:encoded><![CDATA[<p>外部ビットマップデータを読み込んで、ウィンドウ全面に表示されるように拡大・縮小を行います。ウィンドウのサイズが変更されたら、それに合わせてビットマップもリサイズします。<br />
<span class="link"><a href="http://www.almondlab.jp/wp-content/uploads/bitmap-fullscreen"onclick="window.open(this.href); return false;">サンプルはこちら</a></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Bitmap</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Loader</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LoaderInfo</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PixelSnapping</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span>	
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">LoaderInfo</span> = <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//ビットマップデータの読み込み</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onComplete<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;image.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//ステージのスケールを固定で、原点を左上に</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NO_SCALE</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TOP_LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//ビットマップの読み込みが完了した時</span>
			<span style="color: #339966; font-weight: bold;">function</span> onComplete<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> bmd<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> bm<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">PixelSnapping</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NEVER</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//ビットマップを描画</span>
				bmd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">loader</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bm<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				adjustBitmap<span style="color: #000000;">&#40;</span>bm<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//ビットマップをステージのサイズに合わせる</span>
			<span style="color: #339966; font-weight: bold;">function</span> adjustBitmap<span style="color: #000000;">&#40;</span>bm<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">inner</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">/</span>bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//ビットマップの縦横比</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> outer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//ステージの縦横比</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//ステージのサイズが変更された時</span>
				<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">RESIZE</span><span style="color: #000066; font-weight: bold;">,</span> transSize<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				transSize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">//ビットマップを拡大・縮小</span>
				<span style="color: #339966; font-weight: bold;">function</span> transSize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #6699cc; font-weight: bold;">var</span> size_x<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #6699cc; font-weight: bold;">var</span> size_y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageHeight</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
					outer = size_x<span style="color: #000066; font-weight: bold;">/</span>size_y<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
					<span style="color: #009900; font-style: italic;">//ビットマップ、ステージの縦横比を比較してサイズを変更</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">inner</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= outer<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						size_x = size_x<span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">inner</span><span style="color: #000066; font-weight: bold;">/</span>outer<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
						size_y = size_y<span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>outer<span style="color: #000066; font-weight: bold;">/</span><span style="color: #004993;">inner</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #000000;">&#125;</span>
					bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = size_x<span style="color: #000066; font-weight: bold;">;</span>
					bm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = size_y<span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><span class="caption">photo by : Josefrén</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.almondlab.jp/labs/43/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

