<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>イテルの一日一問 &#187; as3勉強</title>
	<atom:link href="http://oneday.ter.jp/tag/as3%e5%8b%89%e5%bc%b7/feed" rel="self" type="application/rss+xml" />
	<link>http://oneday.ter.jp</link>
	<description>一日にひとつは何かを考える。</description>
	<lastBuildDate>Tue, 25 May 2010 00:35:11 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/tag/as3%e5%8b%89%e5%bc%b7/feed" />
		<item>
		<title>継承4</title>
		<link>http://oneday.ter.jp/actionscript3/686.html</link>
		<comments>http://oneday.ter.jp/actionscript3/686.html#comments</comments>
		<pubDate>Wed, 12 Aug 2009 11:01:41 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[ポリモーフィズム]]></category>
		<category><![CDATA[多様態]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=686</guid>
		<description><![CDATA[
継承というのがいまいちどんなときに使ったら良いのかが
分からなかったが、テキストに書いてあることでざくっと分かった気がする。

コードの再利用性を高める役割。
理論的な階層構造を構築する役割。
オブジェクトの複数のタイ [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://oneday.ter.jp/wp-content/uploads/2009/08/0908111.jpg" rel="shadowbox[post-686];player=img;"><img src="http://oneday.ter.jp/wp-content/uploads/2009/08/0908111-700x200.jpg" alt="090811" title="090811" width="700" height="200" class="alignnone size-thumbnail wp-image-720" /></a></p>
<p>継承というのがいまいちどんなときに使ったら良いのかが<br />
分からなかったが、テキストに書いてあることでざくっと分かった気がする。</p>
<ol>
<li>コードの再利用性を高める役割。</li>
<li>理論的な階層構造を構築する役割。</li>
<li>オブジェクトの複数のタイプを、ある単一のタイプが求められる場所で使用できる。</li>
</ol>
<h3>ポリモーフィズム（未解決）</h3>
<p>3番目の「オブジェクトの複数のタイプを、ある単一のタイプが求められる場所で使用できる。」？<br />
どういうこと？<br />
しかも、これを「ポリモーフィズム」というらしい。</p>
<p>ポリモーフィズム＝多様態。<br />
いや分からん。</p>
<blockquote><p>サブクラスのインターフェイスはそのスーパークラスの<br />
インスタンスが期待できる場所ならどこでも使用できます。</p></blockquote>
<p>たぶん、同じコードを何回も書くのはメンドイから、<br />
それを書かなくてもいいようにできるってことみたい。</p>
<p>これならなんとなく意味が分かりそうだけど、言及するのはやめとこ。<br />
これでとりあえず、継承の学習は終了ということで。<br />
まだまだ足りないし、未解決の部分もあるけど、<br />
分かるようになったら、また立ち戻ることにした。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/686.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/686.html" />
	</item>
		<item>
		<title>継承3</title>
		<link>http://oneday.ter.jp/actionscript3/682.html</link>
		<comments>http://oneday.ter.jp/actionscript3/682.html#comments</comments>
		<pubDate>Tue, 11 Aug 2009 11:00:44 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[コンストラクタメソッド]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=682</guid>
		<description><![CDATA[
正直、内容が難しくなって、as3の勉強から逃げてた。
逃げちゃダメだ、逃げちゃダメだ。
でも仕方ないよね。
「にんげんだもの。」
ということで、引き続きas3の継承の勉強を続ける。
サブクラス内のコンストラクタメソッド [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://oneday.ter.jp/wp-content/uploads/2009/08/090811.jpg" rel="shadowbox[post-682];player=img;"><img src="http://oneday.ter.jp/wp-content/uploads/2009/08/090811-700x200.jpg" alt="090811" title="090811" width="700" height="200" class="alignnone size-thumbnail wp-image-717" /></a></p>
<p>正直、内容が難しくなって、as3の勉強から逃げてた。<br />
逃げちゃダメだ、逃げちゃダメだ。<br />
でも仕方ないよね。<br />
「にんげんだもの。」</p>
<p>ということで、引き続きas3の継承の勉強を続ける。</p>
<h3>サブクラス内のコンストラクタメソッドの呼び出し</h3>
<p>「サブクラス内」の「コンストラクタメソッド」と言葉にすると意味が分からん。<br />
コンストラクタメソッドっていうのは、前もやったけどclassで最初に呼び出される<br />
プログラムのことだったと思う。</p>
<p>継承したクラスから親クラスのコンストラクタメソッドを呼び出すってことかな？<br />
それをするには「super()」を使うらしい。</p>
<pre class="brush: as3;">
//class A
public class A {
	//コンストラクタ
	public function A{
	}
}

//class Aを継承したB
public class B extends A{
	//サブクラスのコンストラクタ
	public function B{
		//スーパークラスのコンストラクタメソッドの呼び出し
		super();
	}
}
</pre>
<p>なんかますます分からんようになったかも。<br />
実際に使う現場に直面しないとダメね。<br />
今日はここまで。<br />
これをすると、親クラスAのコンストラクタメソッドが呼び出されるってことか。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/682.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/682.html" />
	</item>
		<item>
		<title>継承2（extends）</title>
		<link>http://oneday.ter.jp/actionscript3/596.html</link>
		<comments>http://oneday.ter.jp/actionscript3/596.html#comments</comments>
		<pubDate>Sun, 02 Aug 2009 14:26:14 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=596</guid>
		<description><![CDATA[
昨日に引き続き、継承を学習する。
静的メソッドと静的変数は継承されない
読んで字のごとくです。

public class iteru{
	public static function hand(){
		trace( [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-598" title="090705-one31" src="http://oneday.ter.jp/wp-content/uploads/2009/08/090705-one311-700x200.jpg" alt="090705-one31" width="700" height="200" /></p>
<p>昨日に引き続き、継承を学習する。</p>
<h3>静的メソッドと静的変数は継承されない</h3>
<p>読んで字のごとくです。</p>
<pre class="brush: as3;">
public class iteru{
	public static function hand(){
		trace(&quot;iteru.hand()が呼び出されました。&quot;)
	}
}
public class koIteru extends iteru{
	public function koIteru(){
		koIteru.hand(); //→エラーになる！！！
	}
}
</pre>
<p>ということ。</p>
<h3>インスタンスメソッドのオーバーライド</h3>
<pre class="brush: as3;">
public class Iteru{
	//スーパークラス内でのインスタンスメソッドの宣言
	public function hand(){
		trace (&quot;Iteruのhandが呼び出された&quot;)
	}
}

//クラスKoIteruのコード
//handをオーバーライドする
public class KoIteru extends Iteru{
	override public function hand(){
		trace(&quot;KoIteruのhandが呼び出された&quot;);
	}
}

//使用すると・・・
var iteruInst = new Iteru();
iteruInst.hand(); //表示：Iteruのhandが呼び出された

var koIteruInst = new KoIteru();
koIteruInst.hand(); //表示：KoIteruのhandが呼び出された
</pre>
<p>というように、Iteruのhandを呼び出せばIteruのhand処理を実行し、<br />
KoIteruを呼び出せば、Iteruのhandを修正した処理、<br />
KoIteruのhand処理が実行される。</p>
<p>なにやら継承からレベルが何段階か上がってきて、<br />
わかりにくくなってきた。<br />
続きはまた明日。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/596.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/596.html" />
	</item>
		<item>
		<title>継承1（extends）</title>
		<link>http://oneday.ter.jp/actionscript3/563.html</link>
		<comments>http://oneday.ter.jp/actionscript3/563.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 23:05:38 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[継承]]></category>
		<category><![CDATA[関数]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=563</guid>
		<description><![CDATA[
本日は、「継承」を学習する。
意味を理解する
継承はオブジェクト指向のプログラムには欠かすことのできないものらしい。
あるクラスが、別のクラスの変数とメソッド定義を借りる（または受け継ぐ）という、
2つ以上のクラスでの [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://oneday.ter.jp/wp-content/uploads/2009/08/090705-one31-700x200.jpg" alt="090705-one31" title="090705-one31" width="700" height="200" class="alignnone size-thumbnail wp-image-592" /></p>
<p>本日は、「継承」を学習する。</p>
<h3>意味を理解する</h3>
<p>継承はオブジェクト指向のプログラムには欠かすことのできないものらしい。<br />
あるクラスが、別のクラスの変数とメソッド定義を借りる（または受け継ぐ）という、<br />
2つ以上のクラスでの形式的名関係性のことを言うらしい。</p>
<p>噛み砕くと、クラスを別のクラスで使えるようにすることらしい。</p>
<p>参考書には、継承させることで継承されたクラスは元のクラスとある点では<br />
そっくりにしながら、他にはないそれ自体の機能を追加することが可能に<br />
なると書いてあった。</p>
<p>「北斗神拳を継承したケン○ロウが、北斗神拳も使いつつ、<br />
それ以外の独自の技を編み出して使えるようになった。」</p>
<p>と同じ意味なのだろうか・・・。<br />
たぶんそうに違いない。</p>
<h3>継承の入門プログラム</h3>
<p>さっそく、入門編の継承のサンプルを書いてみる。</p>
<pre class="brush: as3;">
public class iteru{
	public var iteruVal = 10;

	public function hand(){
		trace(&quot;メソッドhandが実行&quot;);
	}
</pre>
<p>iteruクラスがあったとする。<br />
これを継承したkoIteruクラスを作る。<br />
koIteruクラスにはさらにfootメソッドを追加してみた。</p>
<pre class="brush: as3;">
public class koIteru extends iteru{
	public function foot(){
		trace(&quot;メソッドfootが実行&quot;);
	}
</pre>
<p>koIteruインスタンスはkoIteruと、<br />
そのスーパークラスiteruの持つすべての<br />
メソッドと変数を使うことができるようになる。</p>
<pre class="brush: as3;">
var koIteru = new koIteru();
//iteruから継承した変数を表示
trace(koIteru.iteruVal);  //表示：10

//iteruで定義されている、継承したメソッドの呼び出し
koIteru.hand(); //→表示：メソッドhandが実行

//koIteruで定義されているメソッドの呼び出し。
koIteru.foot(); //→表示：メソッドfootが実行
</pre>
<p>といった感じでkoIteruがiteruの機能を継承したことがわかるはず。<br />
これと同様に、koIteruをmagoIteruが継承すると、<br />
iteruの機能とkoIteruの機能を有したmagoIteruを作れる。</p>
<p>これは便利。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/563.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/563.html" />
	</item>
		<item>
		<title>関数2</title>
		<link>http://oneday.ter.jp/actionscript3/583.html</link>
		<comments>http://oneday.ter.jp/actionscript3/583.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 07:30:01 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[シンタックス]]></category>
		<category><![CDATA[ソースレベル]]></category>
		<category><![CDATA[ネスト]]></category>
		<category><![CDATA[定義]]></category>
		<category><![CDATA[関数]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=583</guid>
		<description><![CDATA[
ネストされた関数
関数に書く関数ってことかな。
この関数の中の関数は、親の関数からのみ使用できるらしい。

//メソッドiteru
public function iteru(){
	//ネストされた関数ito()の呼 [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-588" title="090705-one31" src="http://oneday.ter.jp/wp-content/uploads/2009/07/090705-one315-700x200.jpg" alt="090705-one31" width="700" height="200" /></p>
<h3>ネストされた関数</h3>
<p>関数に書く関数ってことかな。<br />
この関数の中の関数は、親の関数からのみ使用できるらしい。</p>
<pre class="brush: as3;">
//メソッドiteru
public function iteru(){
	//ネストされた関数ito()の呼び出し
	ito();

	//ネストされた関数ito()の定義
	function ito(){
		//関数本体をここに記入
	}
}
</pre>
<p>関数iteruの中で、なんか面倒な処理をさせたい場合に、<br />
面倒な処理を関数itoで実行してしまうって方法。<br />
複雑な計算で、しかも同一関数内で何度も使いそうな場合に使えるかも。</p>
<h3>ソースファイルレベルの関数</h3>
<p>同一ファイル内のパッケージ本体外に書いた関数は、<br />
同じファイル内からだったらどこからでも利用できるっぽい。</p>
<pre class="brush: as3;">
package{
	//ここでもitoは使用可能
	class iteru(){
		//ここでもitoは使用可能
		public function iteru(){
			//ここでもitoは使用可能
		}
	}
}
function ito(){
	//itoの処理
}
</pre>
<p>ちなみに、この関数itoには「function」や「internal」などの<br />
アクセス制御指定子は含めてダメらしい。</p>
<h3>関数内からの定義へのアクセス</h3>
<p>どこに関数を置くかによって、そのプログラムの<br />
定義（変数、メソッド、クラス、名前空間など）に<br />
アクセスできるかが決まるらしい。<br />
詳細説明省略。</p>
<h3>値としての関数</h3>
<p>関数はインスタンスによって表されるので、<br />
値と同じように変数に代入したりすることができる。</p>
<pre class="brush: as3;">
function iteru(){
	//プログラム
}
var ito=iteru;
</pre>
<p>こうすることによって、</p>
<pre class="brush: as3;">
ito();
</pre>
<p>とすると、結果的に「iteru()」を呼びだすことになるらしい。</p>
<h3>関数リテラルのシンタックス</h3>
<p>よくわからんかったｗ</p>
<pre class="brush: as3;">
var square = function(n){
	return n * n;
}

square(5);
</pre>
<p>この方法はsetInterval関数と併用して使用されることがあるらしい。</p>
<pre class="brush: as3;">
package{
	import flash.utils.setInterval;

	public class iteruClock{
		public function iteruClock(){
			//1秒おきに関数リテラルを実行
			setIntval(function(){
				trace(&quot;iteru-tick!&quot;);
			} , 1000 );
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/583.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/583.html" />
	</item>
		<item>
		<title>関数1</title>
		<link>http://oneday.ter.jp/actionscript3/561.html</link>
		<comments>http://oneday.ter.jp/actionscript3/561.html#comments</comments>
		<pubDate>Thu, 30 Jul 2009 11:04:13 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[internal]]></category>
		<category><![CDATA[private]]></category>
		<category><![CDATA[public]]></category>
		<category><![CDATA[関数]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=561</guid>
		<description><![CDATA[
asに限らず、いろいろなプログラムで使われる関数。
正式には関数クロージャと呼ばれるみたい。

関数とは「何らかの作業を実行する個別の命令セット」。
クラスやオブジェクトから独立しているもののことを言うらしい。
関数は [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-569" title="090705-one31" src="http://oneday.ter.jp/wp-content/uploads/2009/07/090705-one314-700x200.jpg" alt="090705-one31" width="700" height="200" /></p>
<p>asに限らず、いろいろなプログラムで使われる関数。<br />
正式には関数クロージャと呼ばれるみたい。</p>
<ol>
<li>関数とは「何らかの作業を実行する個別の命令セット」。</li>
<li>クラスやオブジェクトから独立しているもののことを言うらしい。</li>
<li>関数は「function」キーワードで定義する。</li>
<li>呼び出しにはカッコ演算子を使う。</li>
<li>関数を作成するには、「メソッド内」「パッケージ定義内」<br />
「パッケージ定義外」「別の関数内に直接」に記述する。</li>
<li>直接クラス本体内にあると、それは関数ではなくインスタンスメソッドになる。</li>
</ol>
<p>なんとなく理解できそう・・・。</p>
<p>関数の記述方法は以下の通り。</p>
<pre class="brush: as3;">
function identifier(param1 , param2 , param3 ... paramn){
//プログラムコード
}
</pre>
<p>※identifierは関数の名称。</p>
<p>関数の呼び出し方法は以下の通り。</p>
<pre class="brush: as3;">
theFunction(value1 , value2 , value3 ... valuen);
</pre>
<p>※theFunctionは関数の名称。</p>
<h3>パッケージレベルの関数</h3>
<p>パッケージで関数を使う場合は、関数定義をパッケージ本体内に直接記述する。</p>
<h5>パッケージ内からのみ使える関数</h5>
<pre class="brush: as3;">
package packageName(){
internal function identifier(){
//関数のプログラム
//※アクセス制御指定子internalをつける。
}
}
</pre>
<h5>プログラム全体から使える関数</h5>
<pre class="brush: as3;">
package packageName(){
public function identifier(){
//関数のプログラム
//※アクセス制御指定子publicをつける。
}
}
</pre>
<p>アクセス制御指定子をつけないと自動的にinternalになり、<br />
パッケージ内からのみ使えるようになる。</p>
<h3>グローバル関数</h3>
<p>名前のないパッケージのパッケージレベルで定義した関数は、<br />
「import」ステートメントを使わなくてもプログラム全体から<br />
グローバルに参照することができることから、<br />
グローバル関数と呼ばれる。</p>
<h4>パッケージ名の無い関数例</h4>
<pre class="brush: as3;">
package{
import flash.system.*;
public function isIteru(){
return Capabilities.os = &amp;amp;quot;iteru&amp;amp;quot;
//OSがiteruか確認する。そんなのないけど。
}
}
</pre>
<h4>パッケージ名の無い関数使用例</h4>
<pre class="brush: as3;">
package setup{
public class WelCome{
public function WelCome(){
//isIteruの使用
if( isIteru() ){
//iteru特有のプログラムを実行する
}
}
}
}
</pre>
<p>それとも、isIteruをインポートしなくてもいいってこと・・・。かな。</p>
<p>Flashランタイムにはそれぞれ多くのパッケージレベルの関数や<br />
グローバル関数があらかじめ組み込まれているらしい。</p>
<p>もっとも使うであろうグローバル関数は「trace」。<br />
traceは特にインポートしてなくても使えてるので、<br />
そういった関数を、package名無しで作れば、自作できるってことかと。</p>
<p>今日はここまで。</p>
<div class="amazon-item-box" style="display: block; padding: 0; border: 1px solid  #999; margin: 8px;  -moz-border-radius: 10px;">
<div class="amazon-item-image" style="display: block; padding: 10px; float: left;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank"><img style="border: none; display: inline; vertical-align: bottom;" title="詳説 ActionScript 3.0" src="http://ecx.images-amazon.com/images/I/514SnR1V4yL._SL160_.jpg" alt="詳説 ActionScript 3.0" /></a></div>
<dl class="amazon-item-info" style="display: block; margin-left: 10px; padding: 0 8px 0 10px; font-size: 10pt; line-height: 110%;">
<dt class="amazon-item-name" style="display: block; margin-bottom: 5px; line-height: 120%;"><a title="詳説 ActionScript 3.0" href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank">詳説 ActionScript 3.0</a></dt>
<dd>
<ul class="amazon-item-info-list" style="list-style-type: none; padding-left: 0px; line-height: 120%;">
<li>発売元: オライリージャパン</li>
<li>価格: ￥ 6,090</li>
<li>発売日: 2008/11/22</li>
<li>売上ランキング： 69005</li>
<li>おすすめ度 <img src="http://images-jp.amazon.com/images/G/09/x-locale/common/customer-reviews/stars-5-0.gif" alt="5.0" /></li>
</ul>
</dd>
</dl>
<p class="amazon-item-footer" style="clear: left; text-align: right; font-size: x-small; padding: 4px 10px 4px 10px; line-height: 100%; background-color: #f0f0f0;">posted with <a href="http://socialtunes.net">Socialtunes</a> at 2009/07/27</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/561.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/561.html" />
	</item>
		<item>
		<title>ループ</title>
		<link>http://oneday.ter.jp/actionscript3/558.html</link>
		<comments>http://oneday.ter.jp/actionscript3/558.html#comments</comments>
		<pubDate>Wed, 29 Jul 2009 14:38:52 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[do]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[while]]></category>
		<category><![CDATA[ループ]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=558</guid>
		<description><![CDATA[
条件式に続いてループ文を学習。
書くのがめんどいのでさわりだけということで。
while文

var i=0;
while(i&#60;15);
	trace(&#34;num=&#34;+i);
	i++;
}

 [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://oneday.ter.jp/wp-content/uploads/2009/07/090705-one313-700x200.jpg" alt="090705-one31" title="090705-one31" width="700" height="200" class="alignnone size-thumbnail wp-image-559" /></p>
<p>条件式に続いてループ文を学習。<br />
書くのがめんどいのでさわりだけということで。</p>
<h3>while文</h3>
<pre class="brush: as3;">
var i=0;
while(i&lt;15);
	trace(&quot;num=&quot;+i);
	i++;
}
</pre>
<p>whileはその他の条件式などと合わせても書ける。<br />
配列とかいろいろと。</p>
<p>また、昨日のswitchで出たbreakも使用できるみたい。<br />
ある一定の条件を満たしたら、breakでループを抜けたり。<br />
この辺は、一番下で紹介している詳説Actionscript3.0とか<br />
入門書に詳しく書いてるっす。</p>
<h3>for文</h3>
<p>上記のwhile文と同様にfor文でも書ける。</p>
<pre class="brush: as3;">
var i=0;
for(i=0 ; i &lt; 15 ; i++ ){
	trace(&quot;num=&quot;+i);
}
</pre>
<p>whileで書いたものと全く同じ動きをする。</p>
<pre class="brush: as3;">
for(i=0 ; i &lt; 15 ; i++ ){
</pre>
<blockquote><p>変数「i」の初期値は0で、「i」が15未満ならループして、<br />
ループするときに「i」に位置足してちょ。</p></blockquote>
<p>と、見た目にもわかりやすく1行でokなので、<br />
上記のようなループの場合は私はforを使うかも。</p>
<p>この他にもwhileと似た「do-while」がある。<br />
「do-while」は判別式が後にくるみたい。<br />
使ったことないっす。</p>
<div class="amazon-item-box" style="display: block; padding: 0; border: 1px solid  #999; margin: 8px;  -moz-border-radius: 10px;">
<div class="amazon-item-image" style="display: block; padding: 10px; float: left;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank"><img src="http://ecx.images-amazon.com/images/I/514SnR1V4yL._SL160_.jpg" alt="詳説 ActionScript 3.0" title="詳説 ActionScript 3.0" style="border: none; display: inline; vertical-align: bottom;" /></a></div>
<dl class="amazon-item-info" style="display: block; margin-left: 10px; padding: 0 8px 0 10px; font-size: 10pt; line-height: 110%;">
<dt class="amazon-item-name" style="display: block; margin-bottom: 5px; line-height: 120%;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank" title="詳説 ActionScript 3.0">詳説 ActionScript 3.0</a></dt>
<dd>
<ul class="amazon-item-info-list" style="list-style-type: none; padding-left: 0px; line-height: 120%;">
<li>発売元: オライリージャパン</li>
<li>価格: ￥ 6,090</li>
<li>発売日: 2008/11/22</li>
<li>売上ランキング： 69005</li>
<li>おすすめ度 <img src="http://images-jp.amazon.com/images/G/09/x-locale/common/customer-reviews/stars-5-0.gif" alt="5.0"></li>
</ul>
</dd>
</dl>
<p class="amazon-item-footer" style="clear: left; text-align: right; font-size: x-small; padding: 4px 10px 4px 10px; line-height: 100%; background-color: #f0f0f0;">posted with <a href="http://socialtunes.net">Socialtunes</a> at 2009/07/27</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/558.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/558.html" />
	</item>
		<item>
		<title>条件式</title>
		<link>http://oneday.ter.jp/actionscript3/554.html</link>
		<comments>http://oneday.ter.jp/actionscript3/554.html#comments</comments>
		<pubDate>Tue, 28 Jul 2009 11:40:17 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[roop]]></category>
		<category><![CDATA[while]]></category>
		<category><![CDATA[条件]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=554</guid>
		<description><![CDATA[
プログラムでは付き物な条件とループ。
条件 if文

if(iteru == 1){
	//イテルが1だったら
	trace(&#34;いいよ&#34;);
}else if(iteru == 2){
	//イテル [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://oneday.ter.jp/wp-content/uploads/2009/07/090705-one312-700x200.jpg" alt="090705-one31" title="090705-one31" width="700" height="200" class="alignnone size-thumbnail wp-image-556" /></p>
<p>プログラムでは付き物な条件とループ。</p>
<h3>条件 if文</h3>
<pre class="brush: as3;">
if(iteru == 1){
	//イテルが1だったら
	trace(&quot;いいよ&quot;);
}else if(iteru == 2){
	//イテルが2だったら
	trace(&quot;う、うん&quot;);
}else{
	//1と2以外だったら
	trace(&quot;えっ&quot;);
}
</pre>
<p>といった感じ。<br />
「else if」で複数の式を設けることができる。<br />
これはswitch文でも代替がきく。</p>
<h3>switch</h3>
<pre class="brush: as3;">
switch (iteru){
	case 1:
	trace(&quot;いいよ&quot;);
	break;

	case 2:
	trace(&quot;う、うん&quot;);
	break;

	case 3:
	trace(&quot;えっ&quot;);
	break;
}
</pre>
<p>switch文でも同様に「iteru」の値が1、2、3なら<br />
それぞれのtraceを実行する。</p>
<p>「break」記述するのを忘れてしまわないように。<br />
忘れるとそれ以降のプログラムが実行されてしまうよ。</p>
<div class="amazon-item-box" style="display: block; padding: 0; border: 1px solid  #999; margin: 8px;  -moz-border-radius: 10px;">
<div class="amazon-item-image" style="display: block; padding: 10px; float: left;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank"><img src="http://ecx.images-amazon.com/images/I/514SnR1V4yL._SL160_.jpg" alt="詳説 ActionScript 3.0" title="詳説 ActionScript 3.0" style="border: none; display: inline; vertical-align: bottom;" /></a></div>
<dl class="amazon-item-info" style="display: block; margin-left: 10px; padding: 0 8px 0 10px; font-size: 10pt; line-height: 110%;">
<dt class="amazon-item-name" style="display: block; margin-bottom: 5px; line-height: 120%;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank" title="詳説 ActionScript 3.0">詳説 ActionScript 3.0</a></dt>
<dd>
<ul class="amazon-item-info-list" style="list-style-type: none; padding-left: 0px; line-height: 120%;">
<li>発売元: オライリージャパン</li>
<li>価格: ￥ 6,090</li>
<li>発売日: 2008/11/22</li>
<li>売上ランキング： 69005</li>
<li>おすすめ度 <img src="http://images-jp.amazon.com/images/G/09/x-locale/common/customer-reviews/stars-5-0.gif" alt="5.0"></li>
</ul>
</dd>
</dl>
<p class="amazon-item-footer" style="clear: left; text-align: right; font-size: x-small; padding: 4px 10px 4px 10px; line-height: 100%; background-color: #f0f0f0;">posted with <a href="http://socialtunes.net">Socialtunes</a> at 2009/07/27</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/554.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/554.html" />
	</item>
		<item>
		<title>packageについてちょっと詳しく</title>
		<link>http://oneday.ter.jp/actionscript3/541.html</link>
		<comments>http://oneday.ter.jp/actionscript3/541.html#comments</comments>
		<pubDate>Mon, 27 Jul 2009 11:04:42 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[internal]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[public]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=541</guid>
		<description><![CDATA[
昨日の投稿でpackageについて触れたが、
実はあまり理解していなかったので再度お勉強することに。
イテルを構成するiteruクラス

package iteru{
	//クラスコードを記述
	//コンストラクタ
	 [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://oneday.ter.jp/wp-content/uploads/2009/07/090705-one311-700x200.jpg" alt="090705-one31" title="090705-one31" width="700" height="200" class="alignnone size-thumbnail wp-image-546" /></p>
<p>昨日の投稿でpackageについて触れたが、<br />
実はあまり理解していなかったので再度お勉強することに。</p>
<h3>イテルを構成するiteruクラス</h3>
<pre class="brush: as3;">
package iteru{
	//クラスコードを記述
	//コンストラクタ
	public class VirtualIteru{
		//コンストラクタ
		public function VirtualIteru(){
			//プログラムを記述
		}
	}
}
</pre>
<p>上記のパッケージの書き方でiteruパッケージを作成することになる。</p>
<p>ファイル構造は次のような感じになる。</p>
<p>iteruパッケージ<br />
　|-「src」＝フォルダ<br />
　　　　|-「iteru」＝フォルダ<br />
　　　　　　　|-「VirtualIteru.as」＝asファイル</p>
<p>これを呼び出すときは「iteru.VirtualIteru」となる。</p>
<p>iteruパッケージに、もう１つ、iteruを構成するクラスを作る場合は次のような感じ。</p>
<h3>イテルの手をつかさどる「IteruHand」クラス</h3>
<pre class="brush: as3;">
package iteru{
	public class IteruHand{
		//コンストラクタ
		public function IteruHand(){
			//IteruHand（手）に関するプログラムを記述
		}
	}
}
</pre>
<p>手のクラスを含んだファイル構造は次のような感じになる。</p>
<p>iteruパッケージ<br />
　|-「src」＝フォルダ<br />
　　　　|-「iteru」＝フォルダ<br />
　　　　　　　|-「VirtualIteru.as」＝asファイル<br />
　　　　　　　|-「IteruHand.as」＝asファイル</p>
<h3>IteruHandをVirtualIteruで読み込む</h3>
<p>IteruHandを作ったのは良いが、どうやって使えばいいのかわからん。<br />
ということで、IteruHandをVirtualIteruで読み込む方法は次の通り。</p>
<pre class="brush: as3;">
package iteru{
	//クラスコードを記述
	//コンストラクタ
	public class VirtualIteru{
		//コンストラクタ
		public function VirtualIteru(){
			//プログラムを記述
			new IteruHand();
		}
	}
}
</pre>
<p>IteruHandはパッケージ内にあるため、何もせずとも<br />
読み込むことができる。<br />
しかし、パッケージ外の誰かが作ったパッケージを使いたい場合や<br />
flashに含まれている機能を使いたい場合はパッケージの<br />
読み込みが必要となる。</p>
<p>○サウンド関連のパッケージを使用する例</p>
<pre class="brush: as3;">
package iteru{
	//パッケージのインポート
	import flash.media.Sound;

	public class VirtualIteru{
		public function VirtualIteru(){
			new Sound();
		}
	}
}
</pre>
<p>といった感じでインポートしてnewしなきゃならんらしい。</p>
<h3>アクセス制御指定子</h3>
<p>また、IteruHandクラスを宣言する際に「public」を用いたが、<br />
このクラスはvirtualIteruからしか参照されないので、<br />
「internal」というアクセス制御指定子にもできるようだ。</p>
<p>アクセス制御指定子というのは、どこからまで参照を許可するかという<br />
制御が可能なアレだと思うｗ<br />
パッケージクラスの場合は「public」「internal」の二種類があるっぽい。</p>
<p>publicはパッケージ外からのアクセスが可能。<br />
internalは同一のパッケージからのみアクセスが可能。</p>
<p>・・・ここまではなんとか理解可能。</p>
<div class="amazon-item-box" style="display: block; padding: 0; border: 1px solid  #999; margin: 8px;  -moz-border-radius: 10px;">
<div class="amazon-item-image" style="display: block; padding: 10px; float: left;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank"><img src="http://ecx.images-amazon.com/images/I/514SnR1V4yL._SL160_.jpg" alt="詳説 ActionScript 3.0" title="詳説 ActionScript 3.0" style="border: none; display: inline; vertical-align: bottom;" /></a></div>
<dl class="amazon-item-info" style="display: block; margin-left: 10px; padding: 0 8px 0 10px; font-size: 10pt; line-height: 110%;">
<dt class="amazon-item-name" style="display: block; margin-bottom: 5px; line-height: 120%;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank" title="詳説 ActionScript 3.0">詳説 ActionScript 3.0</a></dt>
<dd>
<ul class="amazon-item-info-list" style="list-style-type: none; padding-left: 0px; line-height: 120%;">
<li>発売元: オライリージャパン</li>
<li>価格: ￥ 6,090</li>
<li>発売日: 2008/11/22</li>
<li>売上ランキング： 69005</li>
<li>おすすめ度 <img src="http://images-jp.amazon.com/images/G/09/x-locale/common/customer-reviews/stars-5-0.gif" alt="5.0"></li>
</ul>
</dd>
</dl>
<p class="amazon-item-footer" style="clear: left; text-align: right; font-size: x-small; padding: 4px 10px 4px 10px; line-height: 100%; background-color: #f0f0f0;">posted with <a href="http://socialtunes.net">Socialtunes</a> at 2009/07/27</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/541.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/541.html" />
	</item>
		<item>
		<title>カスタムクラスを使ってみる（as3）</title>
		<link>http://oneday.ter.jp/actionscript3/526.html</link>
		<comments>http://oneday.ter.jp/actionscript3/526.html#comments</comments>
		<pubDate>Sun, 26 Jul 2009 14:50:12 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[カスタムクラス]]></category>
		<category><![CDATA[パッケージ]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=526</guid>
		<description><![CDATA[
久々にActionscript3の勉強をすることにした。
書式は次のような感じ。

package {
  //パッケージのインポート
  //今回はインポートしない

  //クラスの定義
  public clas [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-529" title="090705-one3" src="http://oneday.ter.jp/wp-content/uploads/2009/07/090705-one31-700x200.jpg" alt="090705-one3" width="700" height="200" /></p>
<p>久々にActionscript3の勉強をすることにした。<br />
書式は次のような感じ。</p>
<pre class="brush: as3;">
package {
  //パッケージのインポート
  //今回はインポートしない

  //クラスの定義
  public class hogeHoge{
    //変数の宣言
    private var hogeVar;

    //コンストラクタ
    public function hogeHoge(){
      hogeVar=&quot;ito&quot;;
      trace(hogeVar);
    }
}
</pre>
<p>カスタムクラスは大まかに上記のような構成。<br />
本に書いてる通りやってみるけど。なんのこっちゃわからん。</p>
<h3>パッケージ：package</h3>
<p>「クラスのグループを収める概念的なコンテナ」とある。<br />
意味があまりわかりませんが、おそらくクラスをまとめたプロジェクト？パッケージ？ｗ<br />
ということなのでしょう。</p>
<pre class="brush: as3;">
package hoge {
}
</pre>
<p>パッケージ名を指定すると例えば、「hoge」パッケージの中の<br />
ひとつのクラスということになるっぽい。</p>
<h3>クラスの定義</h3>
<p>パッケージのクラスを定義する。</p>
<pre class="brush: as3;">
  //クラスの定義
  public class hogeHoge{
  //変数などを定義する
  }
</pre>
<h3>コンストラクタ</h3>
<p>「インスタンスを初期化するために使用される」とのこと。<br />
噛み砕くとコンストラクタはクラスが読み込まれた際に<br />
初めに実行するプログラムってことかな？<br />
ちなみに、省略も可能とのこと。</p>
<pre class="brush: as3;">
    //コンストラクタ
    public function hogeHoge(){
    //プログラムを記述する
    }
</pre>
<p>大きく分けて上記のようなブロックに分かれている。<br />
なんとなく分かってきたような気分になれる。</p>
<div class="amazon-item-box" style="display: block; padding: 0; border: 1px solid  #999; margin: 8px;  -moz-border-radius: 10px;">
<div class="amazon-item-image" style="display: block; padding: 10px; float: left;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank"><img src="http://ecx.images-amazon.com/images/I/514SnR1V4yL._SL160_.jpg" alt="詳説 ActionScript 3.0" title="詳説 ActionScript 3.0" style="border: none; display: inline; vertical-align: bottom;" /></a></div>
<dl class="amazon-item-info" style="display: block; margin-left: 10px; padding: 0 8px 0 10px; font-size: 10pt; line-height: 110%;">
<dt class="amazon-item-name" style="display: block; margin-bottom: 5px; line-height: 120%;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4873113873/iterudiary-22/ref=nosim" target="_blank" title="詳説 ActionScript 3.0">詳説 ActionScript 3.0</a></dt>
<dd>
<ul class="amazon-item-info-list" style="list-style-type: none; padding-left: 0px; line-height: 120%;">
<li>発売元: オライリージャパン</li>
<li>価格: ￥ 6,090</li>
<li>発売日: 2008/11/22</li>
<li>売上ランキング： 69005</li>
<li>おすすめ度 <img src="http://images-jp.amazon.com/images/G/09/x-locale/common/customer-reviews/stars-5-0.gif" alt="5.0"></li>
</ul>
</dd>
</dl>
<p class="amazon-item-footer" style="clear: left; text-align: right; font-size: x-small; padding: 4px 10px 4px 10px; line-height: 100%; background-color: #f0f0f0;">posted with <a href="http://socialtunes.net">Socialtunes</a> at 2009/07/27</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/526.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/526.html" />
	</item>
	</channel>
</rss>
