<?xml version="1.0" encoding="UTF-8" ?>
<feed xml:lang="ja" xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:thr="http://purl.org/syndication/thread/1.0">
  <title type="text">Flash Tech Labo.</title>
  <subtitle type="html">主にFlashのTIPSを紹介するページです。</subtitle>
  <link rel="self" type="application/atom+xml" href="http://flashtechlabo.blog.shinobi.jp/atom"/>
  <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/"/>
  <updated>2009-03-04T17:58:35+09:00</updated>
  <author><name>hirody</name></author>
  <generator uri="//www.ninja.co.jp/blog/" version="0.9">忍者ブログ</generator>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/9</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/actionscript3.0/%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E5%BC%95%E6%95%B0%E3%81%8C%E3%80%81array%E5%9E%8B%E3%81%AE%E5%A0%B4%E5%90%88%E3%81%AE%E5%BC%95%E3%81%8D%E6%B8%A1%E3%81%97%E3%81%8B%E3%81%9F" />
    <published>2010-12-27T17:56:26+09:00</published> 
    <updated>2010-12-27T17:56:26+09:00</updated> 
    <category term="ActionScript3.0" label="ActionScript3.0" />
    <title>ファンクションの引数が、Array型の場合の引き渡しかた</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[ちょっとしたTIPSです。<br />
<br />
引数がArray型のファンクションにパラメータを渡すには、<br />
ダミーの配列を作って、それに格納してから引き渡してる方も<br />
多いかと思いますが、以下の方法が楽で見た目にも分かりやすいです。<br />
<br />
例）<br />
var foo:Array = new Array();<br />
foo.push(&quot;abc&quot;);<br />
foo.push(&quot;xyz&quot;);<br />
hoge(foo);<br />
<br />
&darr;&darr;&darr;<br />
<br />
hoge([&quot;abc&quot;,&quot;xyz&quot;]);<br />
<br />
後からfooを使うのなら別ですが、<br />
ただパラメータを渡したいだけならこれで十分です。<br />
「こんなの常識だよ！」と思われるかもしれませんが、<br />
意外に盲点かと思われます。<br />
なぜなら、私が上記の書き方をしていたからです（笑）<br />
いや～、全然気づかなかったですよ。間抜けですね。<br />
<br />
久しぶりの記事が他愛もない話ですいません&hellip;&hellip;。<br />
<br />]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/7</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/actionscript3.0/html%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AEembed%E3%82%BF%E3%82%B0%E3%81%8B%E3%82%89%E3%80%81swf%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AB%E3%83%91%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF%E3%82%92%E6%B8%A1%E3%81%99-as3.0-" />
    <published>2009-03-24T18:58:54+09:00</published> 
    <updated>2009-03-24T18:58:54+09:00</updated> 
    <category term="ActionScript3.0" label="ActionScript3.0" />
    <title>htmlファイルのembedタグから、swfファイルにパラメータを渡す[AS3.0]</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[※[AS2.0]の場合は、<a href="http://flashtechlabo.blog.shinobi.jp/Entry/6/">こちら</a>を参照してください<br />
<br />
htmlファイルのembedタグからswfファイルにパラメータを渡すには、<br />
AS2.0同様FlashVarsが使える。ただし、Flash側の処理が異なる。<br />
<br />
・&lt;param&gt;タグを１行追加。<br />
・&lt;embed&gt;タグに項目を追加。<br />
<br />
[例]　変数名「option」にパラメータを渡す<br />
<span style="font-family: Courier New;">&lt;param name=&quot;FlashVars&quot; value=&quot;option=value&quot; /&gt;<br />
<br />
&lt;embed FlashVars=&quot;option=value&quot; ... /&gt;<br />
</span><br />
&uarr;ここまでは、AS2.0の時と同じになる。<br />
<br />
■Flash側の処理<br />
<span style="font-family: Courier New;"> var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;<br />
trace( paramObj[&quot;option&quot;] );<br />
</span>のように取り出す。<br />
<br />
また、AS2.0同様「&amp;」で区切ることで、複数指定することができる。<br />
[例]<br />
<span style="font-family: Courier New;">&lt;embed FlashVars=&quot;option=1&amp;version=2&quot; /&gt;<br />
</span><br type="_moz" />]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/6</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/actionscript2.0/html%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AEembed%E3%82%BF%E3%82%B0%E3%81%8B%E3%82%89%E3%80%81swf%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AB%E3%83%91%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF%E3%82%92%E6%B8%A1%E3%81%99-as2.0-" />
    <published>2009-03-24T18:54:24+09:00</published> 
    <updated>2009-03-24T18:54:24+09:00</updated> 
    <category term="ActionScript2.0" label="ActionScript2.0" />
    <title>htmlファイルのembedタグから、swfファイルにパラメータを渡す[AS2.0]</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[※[AS3.0]の場合は、<a href="http://flashtechlabo.blog.shinobi.jp/Entry/7/">こちら</a>を参照してください<br />
<br />
htmlファイルのembedタグからswfファイルにパラメータを渡すには、FlashVarsを使う。<br />
<br />
・&lt;param&gt;タグを１行追加。<br />
・&lt;embed&gt;タグに項目を追加。<br />
<br />
[例]　変数名「option」にパラメータを渡す<br />
&lt;param name=&quot;FlashVars&quot; value=&quot;option=value&quot; /&gt;<br />
<br />
&lt;embed FlashVars=&quot;option=value&quot; ... /&gt;<br />
<br />
■Flash側の処理<br />
trace( _root.option );<br />
のように取り出す。<br />
<br />
また、「&amp;」で区切ることで、複数指定することができる。<br />
[例]<br />
&lt;embed FlashVars=&quot;option=1&amp;version=2&quot; /&gt;<br />
<br />]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/5</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/actionscript3.0/addeventlistener%E3%81%A7%E3%81%AE%E7%84%A1%E5%90%8D%E9%96%A2%E6%95%B0%E5%86%85%E3%81%A7removeeventlistener%E3%82%92%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95-as3.0-" />
    <published>2009-03-18T17:15:45+09:00</published> 
    <updated>2009-03-18T17:15:45+09:00</updated> 
    <category term="ActionScript3.0" label="ActionScript3.0" />
    <title>addEventListenerでの無名関数内でremoveEventListenerをする方法[AS3.0]</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[通常「addEventListener」を使うときは<br />
addEventListener(イベントタイプ, 関数名);<br />
と記述し、イベントが発生したら「関数名」で指定した関数が呼び出される。<br />
<br />
そして処理が終わったら「removeEventListener」で削除する。<br />
removeEventListener(イベントタイプ, 関数名);<br />
<br />
これが基本パターンだが「関数名」の箇所に直接処理を書いてしまうこともできる。<br />
&darr;こんな感じ<br />
addEventListener(イベントタイプ, function(e:Event):void{ trace(&quot;hoge&quot;); });<br />
<br />
しかしこうすると、この関数は名前を持たないので「removeEventListener」する時に困ってしまう。<br />
これを解決するには「arguments.callee」を使う。<br />
&darr;こんな感じ<br />
removeEventListener(イベントタイプ, arguments.callee);<br />
<br />
※「arguments.callee」のヘルプを見ると「現在実行中の関数への参照です」と記述されている<br />
<br />
[プログラム例]：traceを10回実行して、終了する<br />
public function Main()<br />
{<br />
&nbsp;&nbsp;&nbsp; var cnt:int = 0;<br />
&nbsp;&nbsp;&nbsp; addEventListener(Event.ENTER_FRAME,<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; function(e:Event):void<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; trace(&quot;count:&quot;+cnt);<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cnt++;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(cnt==10)<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; removeEventListener(Event.ENTER_FRAME, arguments.callee);<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; );<br />
}<br />
<br />
本当はちゃんと関数を作った方がいいんだろうけど「フラグをセットするだけ」とか、単純な使い方ならプログラムがスッキリする気がしないでもない。。。<br />
でも、あまり使わないかな？<br />
<br type="_moz" />]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/4</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/actionscript3.0/%E8%87%AA%E5%88%86%E8%87%AA%E8%BA%AB%E3%81%8Cstage%E3%81%ABaddchild%E3%81%95%E3%82%8C%E3%81%9F%E3%81%93%E3%81%A8%E3%82%92%E6%A4%9C%E7%9F%A5%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95-as3.0-" />
    <published>2009-03-09T19:16:28+09:00</published> 
    <updated>2009-03-09T19:16:28+09:00</updated> 
    <category term="ActionScript3.0" label="ActionScript3.0" />
    <title>自分自身がstageにaddChildされたことを検知する方法[AS3.0]</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[親クラス内で外部クラスをaddChildした後でなければ、外部クラス内でstageを参照することはできない。<br />
&darr;で、自分自身がaddChildされたことを検知できる。<br />
<br />
public class Test extends Sprite<br />
{<br />
&nbsp;&nbsp;&nbsp; public function Test()<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; trace(stage);&nbsp;&nbsp;&nbsp; // null と表示される<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; addEventListener(Event.ADDED_TO_STAGE, onAdded);&nbsp;&nbsp;&nbsp; // class TestがaddChildされたらonAddedへ<br />
&nbsp;&nbsp;&nbsp; }<br />
<br />
&nbsp;&nbsp;&nbsp; private function onAdded(e:Event)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // この段階でstageが使用可能になる<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; trace(stage);&nbsp;&nbsp;&nbsp; // [object Stage] と表示される<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
<br type="_moz" />]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/3</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/actionscript3.0/%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%82%93%E3%81%A0%E5%A4%96%E9%83%A8swf%E5%86%85%E3%81%AE%E5%A4%89%E6%95%B0%E3%81%AB%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95-as3.0-" />
    <published>2009-03-09T18:43:01+09:00</published> 
    <updated>2009-03-09T18:43:01+09:00</updated> 
    <category term="ActionScript3.0" label="ActionScript3.0" />
    <title>読み込んだ外部swf内の変数にアクセスする方法[AS3.0]</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[例）<br />
読み込まれるファイル：test.swf<br />
変数hogeがある　　　　var hoge:int;<br />
<br />
<br />
var url:URLRequest = new URLRequest(&quot;test.swf&quot;);<br />
var loader:Loader&nbsp; = new Loader();<br />
<br />
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadEnd);<br />
loader.load(url);<br />
<br />
function loadEnd(e:Event)<br />
{<br />
&nbsp;&nbsp;&nbsp; addChild(loader);<br />
<br />
&nbsp;&nbsp;&nbsp; // 変数にアクセスする<br />
&nbsp;&nbsp;&nbsp; var obj:Object = loader.content;<br />
&nbsp;&nbsp;&nbsp; obj.hoge = 123;<br />
&nbsp;&nbsp;&nbsp; trace( obj.hoge );<br />
<br />
&nbsp;&nbsp;&nbsp; // タイムライン制御する<br />
&nbsp;&nbsp;&nbsp; var myMc:MovieClip ;<br />
&nbsp;&nbsp;&nbsp; myMc = loader.content as MovieClip;<br />
&nbsp;&nbsp;&nbsp; myMc.stop();<br />
}<br />
<br type="_moz" />]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/2</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/actionscript3.0/%E5%A4%96%E9%83%A8%E3%82%AF%E3%83%A9%E3%82%B9%E5%86%85%E3%81%A7%E3%80%81%E8%A6%AA%E3%82%AF%E3%83%A9%E3%82%B9%E5%86%85%E3%81%AE%E5%A4%89%E6%95%B0%E3%82%92%E4%BD%BF%E3%81%86-as3.0-" />
    <published>2009-03-04T20:17:48+09:00</published> 
    <updated>2009-03-04T20:17:48+09:00</updated> 
    <category term="ActionScript3.0" label="ActionScript3.0" />
    <title>外部クラス内で、親クラス内の変数を使う[AS3.0]</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<span style="font-family: Courier New;">親クラスの変数にアクセスするような作りは好ましくないが、いざというときのために。。。<br />
<br />
○親クラス<br />
package<br />
{<br />
&nbsp;&nbsp;&nbsp; import flash.display.*;<br />
&nbsp;&nbsp;&nbsp; public class Main extends Sprite<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public var hoge:String = &quot;&quot;;&nbsp;&nbsp;&nbsp; // publicをつけて外部から見えるようにする<br />
<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public function Main()<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var myClass:NewClass = new NewClass();<br />
<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // addChildすることで外部クラスでparentが使えるようになる<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.addChild(myClass);<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myClass.test();<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; trace(hoge);&nbsp;&nbsp;&nbsp; // hogehoge と表示される<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
<br />
○外部クラス<br />
package<br />
{<br />
&nbsp;&nbsp;&nbsp; import flash.display.*;<br />
&nbsp;&nbsp;&nbsp; public class NewClass extends Sprite<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public function test()<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Main(parent).hoge = &quot;hogehoge&quot;;&nbsp;&nbsp;&nbsp; // parentを親クラス名でキャストする<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
<br />
ちなみにアクセスしたい変数のアクセス修飾子を省略すると internal 扱いとなるので、同一パッケージ内からならアクセスが出来る。<br />
<span>public var hoge:String = &quot;&quot;;<br />
&darr;<br />
</span><span>var hoge:String = &quot;&quot;;<br />
</span></span>]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
  <entry>
    <id>flashtechlabo.blog.shinobi.jp://entry/1</id>
    <link rel="alternate" type="text/html" href="http://flashtechlabo.blog.shinobi.jp/%E9%9B%91%E8%AB%87/hello-%20world-" />
    <published>2009-03-04T19:00:41+09:00</published> 
    <updated>2009-03-04T19:00:41+09:00</updated> 
    <category term="雑談" label="雑談" />
    <title>Hello, world!</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[このブログでは、主に「Flash」(ActionScript)についての話題を取り扱います。<br />
<br />
基本的には自分用の備忘録なので、説明もなくプログラムだけが貼り付けてあることもあるかと思いますが、その辺りはご了承ください。<br />
<br />
まぁ、タイトルくらいはつけますが。。。(^_^;<br />
<br />
「自分用の備忘録」というコンセプトなので非公開で作ろうかとも思ったのですが、私自身ネット上のテクニカル系ブログにお世話になることも多いので、こんなブログでも誰かの参考になるかもしれないと思い、公開することにしました。<br />
<br type="_moz" />]]> 
    </content>
    <author>
            <name>hirody</name>
        </author>
  </entry>
</feed>