<?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>macaroni-works notes&#187; class</title>
	<atom:link href="http://blog.macaroniworks.net/tag/class/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.macaroniworks.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 16 Feb 2011 07:27:11 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>AS3 TextFormatを外部クラスにしてみましたが</title>
		<link>http://blog.macaroniworks.net/2009/08/as3-textformat%e3%82%92%e3%82%af%e3%83%a9%e3%82%b9%e3%81%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%81%91%e3%81%a9/</link>
		<comments>http://blog.macaroniworks.net/2009/08/as3-textformat%e3%82%92%e3%82%af%e3%83%a9%e3%82%b9%e3%81%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%81%91%e3%81%a9/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 07:56:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TextFormat]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://blog.macaroniworks.net/?p=816</guid>
		<description><![CDATA[当初staticでクラスメンバとしてやってたのですが 個別に変更する場合難しいので、インスタンスのメンバにしました。 staticのものは以下 AS3 共通のTextFormatを複数のクラスで用いてみる これ本来はsetterとgetterをつかうべきだと思いました。 クラスのプロパティを参照するのはよくないんですよね？ 今度はsetterとgetterについて調べてみます。 ※基礎だとおもいますがおろそかになっています。 TextStyle.as package { import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFormatAlign; class TextStyle { public var textformat_default:TextFormat=new TextFormat(); public var textformat_hover:TextFormat=new TextFormat(); 　　　　　//コンストラクタ function TextStyle() { //初期状態用スタイル textformat_default.size=13; textformat_default.font="_sans"; textformat_default.color=0xEEEEEE; textformat_default.bold=true; //ホバー時状態用スタイル textformat_hover.size=15; textformat_hover.font="_sans"; textformat_hover.color=0xEEEEEE; textformat_hover.bold=true; } } } flaファイル import TextStyle; var text_style=new TextStyle(); var d_format=text_style.textformat_default; var [...]]]></description>
			<content:encoded><![CDATA[<p>当初staticでクラスメンバとしてやってたのですが<br />
個別に変更する場合難しいので、インスタンスのメンバにしました。</p>
<p>staticのものは以下<br />
<a href="http://blog.macaroniworks.net/2009/07/共通のtextformatを複数のクラスで用いてみる。/">AS3 共通のTextFormatを複数のクラスで用いてみる</a></p>
<p>これ本来はsetterとgetterをつかうべきだと思いました。<br />
クラスのプロパティを参照するのはよくないんですよね？<br />
今度はsetterとgetterについて調べてみます。<br />
※基礎だとおもいますがおろそかになっています。</p>
<p><strong>TextStyle.as</strong></p>
<pre class="brush:as3">
package {

	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	class TextStyle {

		public var textformat_default:TextFormat=new TextFormat();
		public var textformat_hover:TextFormat=new TextFormat();

　　　　　//コンストラクタ
		function TextStyle() {
			//初期状態用スタイル
			textformat_default.size=13;
			textformat_default.font="_sans";
			textformat_default.color=0xEEEEEE;
			textformat_default.bold=true;

			//ホバー時状態用スタイル
			textformat_hover.size=15;
			textformat_hover.font="_sans";
			textformat_hover.color=0xEEEEEE;
			textformat_hover.bold=true;
        	}
	}
}
</pre>
<p><strong>flaファイル</strong></p>
<pre class="brush:as3">
import TextStyle;
var text_style=new TextStyle();
var d_format=text_style.textformat_default;
var hover_format=text_style.textformat_hover;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.macaroniworks.net/2009/08/as3-textformat%e3%82%92%e3%82%af%e3%83%a9%e3%82%b9%e3%81%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%81%91%e3%81%a9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 円運動のクラス</title>
		<link>http://blog.macaroniworks.net/2009/08/as3-%e5%86%86%e9%81%8b%e5%8b%95%e3%81%ae%e3%82%af%e3%83%a9%e3%82%b9/</link>
		<comments>http://blog.macaroniworks.net/2009/08/as3-%e5%86%86%e9%81%8b%e5%8b%95%e3%81%ae%e3%82%af%e3%83%a9%e3%82%b9/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 07:38:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DisplayObject]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[円運動]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://blog.macaroniworks.net/?p=778</guid>
		<description><![CDATA[円運動をさせる場合、軸をずらしたmcを作りrotationを変更していたのですが やはり基礎的なところなので作っておきました。 CircleMove.as package { import flash.display.Sprite; import flash.events.Event; public class CircleMove { var my_sprite:Sprite; var my_radius:uint var my_speed:uint; var degree:uint=0; var centerX=0; var centerY=0; var speed:uint; function CircleMove(sprite:Sprite,radius,speed) { my_sprite=sprite; my_radius=radius; my_speed=speed; centerX=my_sprite.x centerY=my_sprite.y my_sprite.addEventListener(Event.ENTER_FRAME,move); } function move(event) { var radian = Math.PI/180*degree; my_sprite.x=centerX+my_radius*Math.cos(radian); my_sprite.y=centerY+my_radius*Math.sin(radian); degree+=my_speed; } } } flaファイルは import CircleMove; var cm=new [...]]]></description>
			<content:encoded><![CDATA[<p>円運動をさせる場合、軸をずらしたmcを作りrotationを変更していたのですが<br />
やはり基礎的なところなので作っておきました。</p>
<p><strong>CircleMove.as</strong></p>
<pre class="brush:as3">
package {
	import flash.display.Sprite;
	import flash.events.Event;

	public class CircleMove {
		var my_sprite:Sprite;
		var my_radius:uint
		var my_speed:uint;
		var degree:uint=0;
		var centerX=0;
		var centerY=0;
		var speed:uint;
		function CircleMove(sprite:Sprite,radius,speed) {
			my_sprite=sprite;
			my_radius=radius;
			my_speed=speed;
			centerX=my_sprite.x
			centerY=my_sprite.y
			my_sprite.addEventListener(Event.ENTER_FRAME,move);
		}
		function move(event) {
			var radian = Math.PI/180*degree;
			my_sprite.x=centerX+my_radius*Math.cos(radian);
			my_sprite.y=centerY+my_radius*Math.sin(radian);
			degree+=my_speed;
		}
	}
}
</pre>
<p>flaファイルは</p>
<pre class="brush:as3">
import CircleMove;
var cm=new CircleMove(ball,100,5);
</pre>
<p>さらに、JSONで渡したかったので継承したクラスを作成しました。<br />
こんなこと普通しなそう・・・</p>
<p><strong>CircleMove2.as</strong></p>
<pre class="brush:as3">
package {
	public class CircleMove2 extends CircleMove {
		function CircleMove2(obj:Object) {
			my_sprite=obj.sprite;
			my_radius=obj.radius;
			my_speed=obj.speed;
			super(my_sprite,my_radius,my_speed);
		}
	}
}
</pre>
<p>この場合のflaファイルは</p>
<pre class="brush:as3">
import CircleMove2;

var cm=new CircleMove2({sprite: ball,radius:100,speed:5});
</pre>
<p>さらに、回転開始のオフセットを設定できるようにしました。<br />
<strong>CircleMove3.as</strong></p>
<pre class="brush:as3">
package {
	public class CircleMove3 extends CircleMove2 {
		function CircleMove3(obj:Object) {
			degree=obj.degree;
			super(obj);
		}
	}
}
</pre>
<p>この場合のサンプルflaファイルは</p>
<pre class="brush:as3">
import CircleMove3;

//リンゲージしたクラスBALL
var ball2=new BALL();
var ball3=new BALL();
prepare(ball2);
prepare(ball3);

//準備用の関数
function prepare(mc:MovieClip){
	mc.x=stage.stageWidth/2;
	mc.y=stage.stageHeight/2;
	addChild(mc);
}

var cm2=new CircleMove2({sprite:ball2,radius:100,speed:5});
var cm3=new CircleMove3({sprite:ball3,radius:100,speed:5,degree:180});//180度から開始
</pre>
<p>となりました。</p>
<p><script type="text/javascript">
			var flashvars = {};
			var params = {};
			var attributes = {};
			swfobject.embedSWF("http://blog.macaroniworks.net/wp-content/uploads/2009/08/CircleMove_test.swf", "	CircleMove_test.swf", "450", "300", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
</script></p>
<div id="	CircleMove_test.swf"></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.macaroniworks.net/2009/08/as3-%e5%86%86%e9%81%8b%e5%8b%95%e3%81%ae%e3%82%af%e3%83%a9%e3%82%b9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 共通のTextFormatを複数のクラスで用いてみる。</title>
		<link>http://blog.macaroniworks.net/2009/07/%e5%85%b1%e9%80%9a%e3%81%aetextformat%e3%82%92%e8%a4%87%e6%95%b0%e3%81%ae%e3%82%af%e3%83%a9%e3%82%b9%e3%81%a7%e7%94%a8%e3%81%84%e3%81%a6%e3%81%bf%e3%82%8b%e3%80%82/</link>
		<comments>http://blog.macaroniworks.net/2009/07/%e5%85%b1%e9%80%9a%e3%81%aetextformat%e3%82%92%e8%a4%87%e6%95%b0%e3%81%ae%e3%82%af%e3%83%a9%e3%82%b9%e3%81%a7%e7%94%a8%e3%81%84%e3%81%a6%e3%81%bf%e3%82%8b%e3%80%82/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 07:16:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TextFormat]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[定数]]></category>

		<guid isPermaLink="false">http://blog.macaroniworks.net/?p=532</guid>
		<description><![CDATA[共通のテキストフォーマットを複数のクラスで用いてみる。 なんかこれ絶対損してます。とりあえずはコレで！ staticを利用することにより インスタンスをつくらず直接利用できるところがミソです。 定数をいろいろ定義するファイルとしてクラスを利用するという概念も あるのですね。 package { import flash.text.TextFormat; import flash.text.TextFormatAlign; public class TextStyle { static var chart_textformat:TextFormat=new TextFormat(); chart_textformat.font="_sans"; chart_textformat.size=20; chart_textformat.color=0x555555; chart_textformat.align=TextFormatAlign.CENTER; } } これが利用するクラス package { import TextStyle; public class SampleClass { var chart_textformat=TextStyle.chart_textformat; } }]]></description>
			<content:encoded><![CDATA[<p>共通のテキストフォーマットを複数のクラスで用いてみる。<br />
なんかこれ絶対損してます。とりあえずはコレで！</p>
<p><strong>static</strong>を利用することにより<br />
インスタンスをつくらず直接利用できるところがミソです。<br />
定数をいろいろ定義するファイルとしてクラスを利用するという概念も<br />
あるのですね。</p>
<pre class="brush:as3">
package {
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public class TextStyle {
		static var chart_textformat:TextFormat=new TextFormat();
		chart_textformat.font="_sans";
		chart_textformat.size=20;
		chart_textformat.color=0x555555;
		chart_textformat.align=TextFormatAlign.CENTER;
	}
}
</pre>
<p>これが利用するクラス</p>
<pre class="brush:as3">
package {
	import TextStyle;
	public class SampleClass {
		var chart_textformat=TextStyle.chart_textformat;
        }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.macaroniworks.net/2009/07/%e5%85%b1%e9%80%9a%e3%81%aetextformat%e3%82%92%e8%a4%87%e6%95%b0%e3%81%ae%e3%82%af%e3%83%a9%e3%82%b9%e3%81%a7%e7%94%a8%e3%81%84%e3%81%a6%e3%81%bf%e3%82%8b%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

