<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>teon FACTORY NotePad</title>
    <link>http://www.teon-factory.com/nc/</link>
    <description>スクリプトとかのメモ。</description>
    <!-- optional tags -->
    <language>ja</language>           <!-- valid langugae goes here -->
    <generator>Nucleus CMS v3.24</generator>
    <copyright>ｩ</copyright>             <!-- Copyright notice -->
    <category>Weblog</category>
    <docs>http://backend.userland.com/rss</docs>
    <image>
      <url>http://www.teon-factory.com/nc//nucleus/nucleus2.gif</url>
      <title>teon FACTORY NotePad</title>
      <link>http://www.teon-factory.com/nc/</link>
    </image>
    <item>
 <title><![CDATA[リンゲージしているサウンドを鳴らす関数]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=10</link>
<description><![CDATA[<pre style="background-color:#FFD1D1;">
function testS(){
	testSound = new Sound();
	testSound.attachSound("test_se");
	testSound.start();
}
</pre>本当にアッタチしているだけ。<br />
<br />
ボタンを押した際のSEなどに。<br />
"test_se"<br />
っていうのがリンゲージした名前。<br />
<br />
<pre>
testS();
</pre>
で実行。<br />
<br />
MCのタイムラインに直接サウンドを張るものとは違い、<br />
鳴らすたびにnewでサウンドが追加されるので<br />
連打すると音が重なって出力されます。
]]></description>
 <category>ActionScript</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=10</comments>
 <pubDate>Thu, 15 Jan 2009 16:13:41 +0900</pubDate>
</item><item>
 <title><![CDATA[PHPに読み込ませているライブラリのパスをスクリプト上で追加]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=9</link>
<description><![CDATA[<pre style="background-color:#CCFF99;">
$path = ini_get('include_path');
$path .= ":/var/www/example.com/lib/PEAR/";
ini_set('include_path', $path);
</pre>
<p>インストールされているPEARのバージョンが低いなどの原因で、<br />
デフォルトのパス内から必要なライブラリのファイルが無い場合<br />
＋<br />
委託案件でインストールする権限が自分にない(依頼して反映までに時間、手間がかかる)場合<br />
によく使用しています。</p>

<p>参照するパスはローカルの絶対パスを記述。</p>]]></description>
 <category>PHP</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=9</comments>
 <pubDate>Tue, 24 Jun 2008 13:48:20 +0900</pubDate>
</item><item>
 <title><![CDATA[変数チェック]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=8</link>
<description><![CDATA[<pre style="background-color:#CCFF99;">
function getTypeCheck($getchk){
	if(preg_match("/^[0-9,a-z,A-Z,_]+$/", $getchk) || $getchk == ""){
		return $getchk;
	}else{
		exit('Errer');
	}
}
</pre><p>GETなどで送られてきたパラメータの確認。</p>

<p>
構文では<br />
送られてきた変数が
</p>

<p>
0～9<br />
a～z<br />
A～Z
</p>

<p>
の半角英数字、
</p>

<p>
半角の"_"
</p>

<p>
以外の文字列が含まれていた場合、
</p>

<p>
もしくは<br />
パラメータが空だった場合<br />
以外は
</p>

<p>
「Errer」と文字列を出力して<br />
スクリプトを停止します。
</p>

<p>
問題がなかった場合は<br />
受け取った変数をそのまま返します。
</p>

<p>
実行は
</p>
<pre style="background-color:#CCFF99;">
$get_var = getTypeCheck($_GET['var']);
</pre>

<p>
こんなイメージです。
</p>

<p>
どうでもいいですが、エラーを全角で出したい場合は
</p>

<pre style="background-color:#CCFF99;">
function getTypeCheck($getchk){
	if(preg_match("/^[0-9,a-z,A-Z,_]+$/", $getchk) || $getchk == ""){
		return $getchk;
	}else{
		$mes = mb_convert_encoding('不正なパラメータです。' , "UTF-8");
		exit($mes);
	}
}
</pre>

<p>
と、やってあげればいいんじゃなかろうかと。<br />
別に"UTF-8"の部分の文字コードは、なんでもいいんですが。
</p>]]></description>
 <category>PHP</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=8</comments>
 <pubDate>Wed, 5 Mar 2008 15:29:21 +0900</pubDate>
</item><item>
 <title><![CDATA[「.html」の中でphpが動かないとです・・・]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=7</link>
<description><![CDATA[<pre style="background-color:#ceffff;">
&lt;Files index.html&gt;
	AddType application/x-httpd-php .html
&lt;/Files&gt;
</pre>
]]></description>
 <category>.htaccess</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=7</comments>
 <pubDate>Thu, 24 May 2007 20:47:19 +0900</pubDate>
</item><item>
 <title><![CDATA[外部のCSVを読み込んで配列化]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=6</link>
<description><![CDATA[<pre style="background-color:#FFD1D1;">
xmlobject = new XML();

xmlobject.onData = function(source_str){
	lines = new Array();
	csv = new Array();
	lines = source_str.split("\n");	//1行の区切り文字(ここでは改行コード)
	
	for(i=0;i&lt;lines.length;i++){
		tmp_array = new Array();
		tmp_array = lines[i].split("\t");	//1項目の区切り文字(ここではTab)
		tmpNo = Number(tmp_array[0]);
		tmpCode = tmp_array[1];
		tmpName =  tmp_array[2];
		tmpEn = tmp_array[3];
		tmpObj = {no:tmpNo,code:tmpCode,nm:tmpName,en:tmpEn};
		csv.push(tmpObj);
	}
}

xmlobject.load("list.csv");	//外部のCSVファイルまでのパス
</pre>上記の例では<br />
csvという名前の変数に配列になって格納されます。<br />
<br />
list.csvの内容<br />
<pre style="background-color:#CCCCCC;">
1	A	山田	yamada
2	B	佐藤	sato
3	C	鈴木	suzuki
</pre>
※ダブルバイトの文字列がある場合はUTF-8で設定。<br />
　もしくはコードの先頭に<br />
<pre style="background-color:#FFD1D1;">
System.useCodepage = true;	//※MX以降
</pre>
と記述。<br />
<br />
項目の参照は<br />
<pre style="background-color:#FFD1D1;">
trace(csv[2].name);	//←佐藤
trace(csv[1].code);	//←A
trace(csv[3].en);	//←suzuki
</pre>
で。<br />
<br />
でも単に↑を書いただけだとcsvファイルの読み込みが完了しないままtrace()が実行されてしまうので<br />
別途、ローダーとかでファイルのロードが完了してから実行しないとダメです。<br />
<br />
<pre style="background-color:#FFD1D1;">
onEnterFrame = function(){
	trace(csv[2].name);	//←佐藤
	trace(csv[1].code);	//←A
	trace(csv[3].en);	//←suzuki
}
</pre>
とか書くとわかりやすいかも。<br />
最初、undefined で<br />
途中から正しい結果が返ってくると思います。<br />
]]></description>
 <category>ActionScript</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=6</comments>
 <pubDate>Wed, 18 Apr 2007 20:02:26 +0900</pubDate>
</item><item>
 <title><![CDATA[String拡張・replace関数(文字置換)]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=5</link>
<description><![CDATA[<pre style="background-color:#FFD1D1;">
String.prototype.replace = function( from_str, to_str ){
	return this.split(from_str).join(to_str);
}
</pre>
第1パラメータ：検索する文字列<br />
第2パラメータ：置換する文字列<br />
<br />
(変数の中にある)文字列の中を検索して<br />
指定した文字列に置き換えます。<br />
<br />
<b>実行例</b><br />
<pre style="background-color:#FFD1D1;">
//改行削除
bar_str = foo_str.replace("\n", "");

//文字列"ABC"　→　文字列"XYZ"
foo_str = "ABCの歌";
bar_str = foo_str.replace("ABC", "XYZ");
trace(bar_str);	//XYZの歌
</pre>
]]></description>
 <category>ActionScript</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=5</comments>
 <pubDate>Fri, 13 Apr 2007 17:02:51 +0900</pubDate>
</item><item>
 <title><![CDATA[ランダムの数字を返す関数]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=4</link>
<description><![CDATA[<pre style="background-color:#FFD1D1;">
function rand(min,max) {
	sa = max - min;
	randNum = Math.random() ;
	if (randNum == 1){
		randNum=0;
	}
	result = Math.floor(randNum* (sa+1))+min;
	return result;
}
</pre>
当時、教えて頂きながら。<br />
<br />
第1パラメータ：最小値<br />
第2パラメータ：最大値<br />
<br />
<b>実行例</b><br />
<pre style="background-color:#FFD1D1;">
//※１から10までのどれかをランダムで取得
kekka = rand(1,10);
trace(kekka);	//○ (1～10のどれか)
</pre>
<br />
Math.random()<br />
での返り値の再計算とか変換が面倒くさい時用。<br />
<br />
<pre style="background-color:#FFD1D1;">
trace(array[rand(1,10)]);
</pre>
とか。<br />
<br />
配列使って<br />
一度、取得した値は返らないVerも作ろう。<br />
]]></description>
 <category>ActionScript</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=4</comments>
 <pubDate>Thu, 12 Apr 2007 22:03:37 +0900</pubDate>
</item><item>
 <title><![CDATA[【ご注意】]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=3</link>
<description><![CDATA[掲載している情報に対しての注意・免責事項ですが、<br />
<br />
このblogに掲載しているスクリプトは個人で作成したものであり、<br />
そしてあくまでメモ程度のレベルです。<br />
<strong>このblogに掲載しているスクリプトを使用したことによる、<br />
いかなる損害も作者(teon)は一切の責任を負いません。</strong><br />
<br />
すべてのスクリプトは、すべての環境での動作を保証するものではありません。<br />
当然、ソフト・ハードウェアの設定などに依存しますし<br />
作者(teon)がスクリプトを十分な検証せずに掲載してしまう場合もあります。<br />
<strong>また、掲載しているスクリプトの設置や設定方法に関するサポートの義務も<br />
作者(teon)は一切を負いません。</strong><br />
<br />
作者(teon)は公開しているスクリプトを予告なく削除、修正する場合があります。<br />
]]></description>
 <category>【ご注意】</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=3</comments>
 <pubDate>Thu, 12 Apr 2007 17:19:40 +0900</pubDate>
</item><item>
 <title><![CDATA[テスト]]></title>
 <link>http://www.teon-factory.com/nc/index.php?itemid=2</link>
<description><![CDATA[テスト(・∀・)]]></description>
 <category>PHP</category>
<comments>http://www.teon-factory.com/nc/index.php?itemid=2</comments>
 <pubDate>Thu, 12 Apr 2007 13:13:59 +0900</pubDate>
</item>
  </channel>
</rss>
