<?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>opentransmission</title>
	<atom:link href="http://opentransmission.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://opentransmission.com</link>
	<description>Interactive Design, Development and Animation by Eric Cohen</description>
	<lastBuildDate>Fri, 19 Feb 2010 02:21:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Native 3D Flash Interface</title>
		<link>http://opentransmission.com/2010/02/native-3d-flash-interface/</link>
		<comments>http://opentransmission.com/2010/02/native-3d-flash-interface/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 00:10:17 +0000</pubDate>
		<dc:creator>Eric Cohen</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://escohen.com/?p=62</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Block3d_1084992163"
			class="flashmovie"
			width="665"
			height="300">
	<param name="movie" value="http://www.opentransmission.com/shared/flash/Block3d.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.opentransmission.com/shared/flash/Block3d.swf"
			name="fm_Block3d_1084992163"
			width="665"
			height="300">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>Little experiment with native Flash 3D. I had been playing around with Papervision and needed a simple way to deal with a single element of an application as a 3D object. I found Flash Player 10&#8217;s matrix3D adequate for this purpose. Papervision requires a lot of processing power and longer compile [...]]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Block3d_1844217302"
			class="flashmovie"
			width="665"
			height="300">
	<param name="movie" value="http://www.opentransmission.com/shared/flash/Block3d.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.opentransmission.com/shared/flash/Block3d.swf"
			name="fm_Block3d_1844217302"
			width="665"
			height="300">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>Little experiment with native Flash 3D. I had been playing around with Papervision and needed a simple way to deal with a single element of an application as a 3D object. I found Flash Player 10&#8217;s matrix3D adequate for this purpose. Papervision requires a lot of processing power and longer compile times. If you&#8217;re working with Flex, you&#8217;ll need to have the most recent SDK that compiles to Flash 10. Using native 3D is an easy way to add 3D to your projects by simply applying matrix3D properties to your elements. <span id="more-62"></span><br />
<br />
Here I&#8217;ve set a container and arranged blocks into a grid. If you click on a block, it changes it&#8217;s z and rotationY properties. On the &#8220;back&#8221; of the block is a second block set back in z space one pixel. When the block flips around, the front block is turned invisible and the back turned visible. On mouse out, the reverse happens.<br />
<br />
The hardest thing was working around the fact that it doesn&#8217;t support a double sided plane. I hacked around this by putting the back face with a scale of -1 and setting the visibilities of the front and back faces on a timer that goes off while the plane is turns 90 degrees.<br />
<br />
<a class="download" href="http://www.opentransmission.com/downloads/Block3D.zip", target"_blank"><b>Download Source</b></a></p>
<h5>Block3D.as</h5>

<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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">MouseEvent</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">transitions</span>.<span style="color: #000000;">Tween</span>;
 	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">transitions</span>.<span style="color: #000000;">easing</span>.<span style="color: #66cc66;">*</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">transitions</span>.<span style="color: #000000;">TweenEvent</span>;
&nbsp;
   	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Block3D <span style="color: #0066CC;">extends</span> Sprite 
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> NUM_SQUARES:uint = <span style="color: #cc66cc;">15</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> NUM_ACROSS:uint = <span style="color: #cc66cc;">5</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> BLOCK_OFFSET:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">100</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> container:Sprite;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> easeOut:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0.3</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> rotX:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0.1</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> rotY:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0.1</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> scaleTween:Tween;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> rotationTween:Tween;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> activeSquare:<span style="color: #0066CC;">Object</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> front:BlockFaces;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> back:BlockFaces;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Block3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			buildDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			positionDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">stage</span>.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #000000;">MOUSE_OVER</span>, enterMovieHandler<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #000000;">MOUSE_LEAVE</span>, leaveMovieHandler<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> buildDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			container = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
			addChild<span style="color: #66cc66;">&#40;</span>container<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> blockXPos:<span style="color: #0066CC;">Number</span> = -<span style="color: #cc66cc;">200</span>;
			<span style="color: #000000; font-weight: bold;">var</span> blockYPos:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
			<span style="color: #000000; font-weight: bold;">var</span> blockNum:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
			<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> NUM_SQUARES; i++<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> block:Block = <span style="color: #000000; font-weight: bold;">new</span> Block<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				block.<span style="color: #000000;">itemNum</span> = i;
				container.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>block<span style="color: #66cc66;">&#41;</span>;
&nbsp;
				block.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #000000;">MOUSE_OVER</span>, scaleBlock<span style="color: #66cc66;">&#41;</span>;
				block.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #000000;">MOUSE_OUT</span>, scaleBlock<span style="color: #66cc66;">&#41;</span>;
				block.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #000000;">MOUSE_DOWN</span>, scaleBlock<span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>blockNum <span style="color: #66cc66;">&lt;</span> NUM_ACROSS -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
					block.<span style="color: #000000;">x</span> = blockXPos;
					block.<span style="color: #000000;">y</span> = blockYPos;
					blockXPos += BLOCK_OFFSET;
					blockNum++;
				<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
					block.<span style="color: #000000;">x</span> = blockXPos;
					block.<span style="color: #000000;">y</span> = blockYPos;
					blockYPos += BLOCK_OFFSET;
					blockXPos = -<span style="color: #cc66cc;">200</span>;
					blockNum = <span style="color: #cc66cc;">0</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> positionDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			container.<span style="color: #000000;">x</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #000000;">stageWidth</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;
			container.<span style="color: #000000;">y</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #000000;">stageHeight</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span> - container.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span> + BLOCK_OFFSET<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;
			container.<span style="color: #000000;">z</span> = <span style="color: #cc66cc;">200</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> scaleBlock<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">case</span> MouseEvent.<span style="color: #000000;">MOUSE_OVER</span>:;
				scaleTween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>, <span style="color: #ff0000;">&quot;z&quot;</span>, Regular.<span style="color: #000000;">easeOut</span>, <span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">z</span>, -<span style="color: #cc66cc;">200</span>, .3, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
				container.<span style="color: #000000;">setChildIndex</span><span style="color: #66cc66;">&#40;</span>Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span><span style="color: #66cc66;">&#41;</span>, container.<span style="color: #000000;">numChildren</span> - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">break</span>;
&nbsp;
&nbsp;
				<span style="color: #b1b100;">case</span> MouseEvent.<span style="color: #000000;">MOUSE_OUT</span>:
				scaleTween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>, <span style="color: #ff0000;">&quot;z&quot;</span>, Regular.<span style="color: #000000;">easeOut</span>, <span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">z</span>, <span style="color: #cc66cc;">0</span>, .3, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">rotationY</span> <span style="color: #66cc66;">&gt;</span>= <span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
					rotationTween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>, <span style="color: #ff0000;">&quot;rotationY&quot;</span>, Regular.<span style="color: #000000;">easeOut</span>, <span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">rotationY</span>, <span style="color: #cc66cc;">0</span>, .3, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
					<span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">frontFlip</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
				<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> MouseEvent.<span style="color: #000000;">MOUSE_DOWN</span>:
				<span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">z</span> = -<span style="color: #cc66cc;">200</span>;
				rotationTween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>, <span style="color: #ff0000;">&quot;rotationY&quot;</span>, Regular.<span style="color: #000000;">easeOut</span>, <span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">rotationY</span>, <span style="color: #cc66cc;">180</span>, .3, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #0066CC;">e</span>.<span style="color: #000000;">currentTarget</span>.<span style="color: #000000;">backFlip</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mouseOverHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> xDist:<span style="color: #0066CC;">Number</span> = mouseX - <span style="color: #0066CC;">stage</span>.<span style="color: #000000;">stageWidth</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">0.5</span>;
			<span style="color: #000000; font-weight: bold;">var</span> yDist:<span style="color: #0066CC;">Number</span> = mouseY - <span style="color: #0066CC;">stage</span>.<span style="color: #000000;">stageHeight</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">0.5</span>;
			container.<span style="color: #000000;">rotationY</span> += <span style="color: #66cc66;">&#40;</span>xDist <span style="color: #66cc66;">*</span> rotY - container.<span style="color: #000000;">rotationY</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> easeOut;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enterMovieHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #000000;">ENTER_FRAME</span>, mouseOverHandler<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> leaveMovieHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			removeEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #000000;">ENTER_FRAME</span>, mouseOverHandler<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h5>Block.as</h5>

<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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextFormat</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #000000;">TextFormatAlign</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #000000;">AntiAliasType</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">TimerEvent</span>;
    	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">utils</span>.<span style="color: #000000;">Timer</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Block <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _number:uint;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> front:BlockFaces;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> back:BlockFaces;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> t1:Timer;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> t2:Timer;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Block<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			front = <span style="color: #000000; font-weight: bold;">new</span> BlockFaces<span style="color: #66cc66;">&#40;</span>0xFF0000<span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>front<span style="color: #66cc66;">&#41;</span>;
			front.<span style="color: #000000;">itemNum</span> = _number;
			front.<span style="color: #000000;">mouseEnabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			front.<span style="color: #000000;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
			back = <span style="color: #000000; font-weight: bold;">new</span> BlockFaces<span style="color: #66cc66;">&#40;</span>0x0000FF<span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>back<span style="color: #66cc66;">&#41;</span>;
			back.<span style="color: #000000;">itemNum</span> = _number;
			back.<span style="color: #000000;">mouseEnabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			back.<span style="color: #000000;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			back.<span style="color: #000000;">z</span> = -<span style="color: #cc66cc;">1</span>;
			back.<span style="color: #000000;">scaleX</span> = -<span style="color: #cc66cc;">1</span>;
			back.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> itemNum<span style="color: #66cc66;">&#40;</span>num:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_number = num;
			front.<span style="color: #000000;">itemNum</span> = _number;
			back.<span style="color: #000000;">itemNum</span> = _number;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> frontFlip<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			t1 = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
           			t1.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #000000;">TIMER</span>, timerHandler<span style="color: #66cc66;">&#41;</span>;
			t1.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> backFlip<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			t2 = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
			t2.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #000000;">TIMER</span>, timerHandler2<span style="color: #66cc66;">&#41;</span>;
			t2.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> timerHandler<span style="color: #66cc66;">&#40;</span>event:TimerEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			t1.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			front.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			back.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> timerHandler2<span style="color: #66cc66;">&#40;</span>event:TimerEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			t2.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			front.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			back.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h5>BlockFaces.as</h5>

<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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextFormat</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #000000;">TextFormatAlign</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #000000;">AntiAliasType</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BlockFaces <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _number:uint;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> tFTitle:<span style="color: #0066CC;">TextField</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> BlockFaces<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">color</span>:uint<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> square:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>square<span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,0xffffff<span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">color</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #000000;">drawRect</span><span style="color: #66cc66;">&#40;</span>-<span style="color: #cc66cc;">50</span>,-<span style="color: #cc66cc;">50</span>,<span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> fmt:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			fmt.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">16</span>;
			fmt.<span style="color: #0066CC;">color</span> = 0xcccccc;
			fmt.<span style="color: #0066CC;">align</span> = TextFormatAlign.<span style="color: #0066CC;">LEFT</span>;
			fmt.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial&quot;</span>;
&nbsp;
			tFTitle = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			tFTitle.<span style="color: #000000;">defaultTextFormat</span> = fmt;
			tFTitle.<span style="color: #0066CC;">selectable</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			tFTitle.<span style="color: #000000;">antiAliasType</span> = AntiAliasType.<span style="color: #000000;">ADVANCED</span>;
			tFTitle.<span style="color: #0066CC;">border</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			tFTitle.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			tFTitle.<span style="color: #000000;">mouseEnabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			square.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>tFTitle<span style="color: #66cc66;">&#41;</span>;
			tFTitle.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">100</span>;
			tFTitle.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">50</span>;
			tFTitle.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
			tFTitle.<span style="color: #000000;">x</span> = -<span style="color: #cc66cc;">50</span>;
			tFTitle.<span style="color: #000000;">y</span> = -<span style="color: #cc66cc;">50</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> itemNum<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _number;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> itemNum<span style="color: #66cc66;">&#40;</span>num:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_number = num;
			tFTitle.<span style="color: #0066CC;">text</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>_number + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://opentransmission.com/2010/02/native-3d-flash-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweener Text Swap Animation</title>
		<link>http://opentransmission.com/2010/01/tweener-text-swap-animation/</link>
		<comments>http://opentransmission.com/2010/01/tweener-text-swap-animation/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 23:36:56 +0000</pubDate>
		<dc:creator>Eric Cohen</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Animation]]></category>

		<guid isPermaLink="false">http://escohen.com/?p=17</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TweenerSwap_1886062108"
			class="flashmovie"
			width="665"
			height="70">
	<param name="movie" value="http://www.opentransmission.com/shared/flash/TweenerSwap.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.opentransmission.com/shared/flash/TweenerSwap.swf"
			name="fm_TweenerSwap_1886062108"
			width="665"
			height="70">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>I came across this little trick and think it&#8217;s a great way to swap out copy in an easy and unique way. Using one of Tweener&#8217;s Textshortcut properties, you can change the copy in a textfield by tweening between strings. Typically I try to use native Flash tweening in these prototypes, [...]]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TweenerSwap_1838024755"
			class="flashmovie"
			width="665"
			height="70">
	<param name="movie" value="http://www.opentransmission.com/shared/flash/TweenerSwap.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.opentransmission.com/shared/flash/TweenerSwap.swf"
			name="fm_TweenerSwap_1838024755"
			width="665"
			height="70">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>I came across this little trick and think it&#8217;s a great way to swap out copy in an easy and unique way. Using one of Tweener&#8217;s Textshortcut properties, you can change the copy in a textfield by tweening between strings. Typically I try to use native Flash tweening in these prototypes, but Tweener has this transition not found in Flash&#8217;s framework. <span id="more-17"></span><br />
<br />
Here, an event listener waits for a button to be clicked. Depending on which button is clicked, it sets the string to new copy and changes the size of the sprite behind it.  For this to work, download the newest Tweener AS3 classes from <a href ="http://code.google.com/p/tweener/" target="_blank">http://code.google.com/p/tweener/</a> and include it in your project with the import statements in the first few lines of the TweenerSwap class.<br />
<br />
<a class="download" href="http://www.opentransmission.com/downloads/TweenerSwap.zip", target"_blank"><b>Download Source</b></a></p>
<h5>Main.as</h5>

<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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> caurina.<span style="color: #000000;">transitions</span>.<span style="color: #000000;">Tweener</span>;
	<span style="color: #0066CC;">import</span> caurina.<span style="color: #000000;">transitions</span>.<span style="color: #000000;">properties</span>.<span style="color: #000000;">TextShortcuts</span>;
	TextShortcuts.<span style="color: #000000;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">MouseEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextFormat</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #000000;">TextFormatAlign</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #000000;">AntiAliasType</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">controls</span>.<span style="color: #0066CC;">Button</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TweenerSwap <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> btn1:<span style="color: #0066CC;">Button</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> btn2:<span style="color: #0066CC;">Button</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> btn3:<span style="color: #0066CC;">Button</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> squContainer:Sprite;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> square:Sprite;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> tF:<span style="color: #0066CC;">TextField</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> textStr:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> squWidth:<span style="color: #0066CC;">Number</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> squHeight:<span style="color: #0066CC;">Number</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> TweenerSwap<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			format<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			squContainer = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>squContainer<span style="color: #66cc66;">&#41;</span>;
			squContainer.<span style="color: #000000;">alpha</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
			square = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			squContainer.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>square<span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFF0000, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #000000;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> fmt:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			fmt.<span style="color: #0066CC;">font</span>=<span style="color: #ff0000;">&quot;Arial&quot;</span>;
			fmt.<span style="color: #0066CC;">size</span>=<span style="color: #cc66cc;">12</span>;
			fmt.<span style="color: #0066CC;">color</span>= 0xCCCCCC;
			fmt.<span style="color: #0066CC;">leading</span>=<span style="color: #cc66cc;">4</span>;
			fmt.<span style="color: #0066CC;">align</span> = TextFormatAlign.<span style="color: #000000;">CENTER</span>;
&nbsp;
			tF = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			tF.<span style="color: #0066CC;">multiline</span>=<span style="color: #000000; font-weight: bold;">true</span>;
			tF.<span style="color: #0066CC;">wordWrap</span>=<span style="color: #000000; font-weight: bold;">true</span>;
			tF.<span style="color: #0066CC;">width</span>=<span style="color: #cc66cc;">300</span>;
			tF.<span style="color: #0066CC;">selectable</span>=<span style="color: #000000; font-weight: bold;">false</span>;
			tF.<span style="color: #000000;">defaultTextFormat</span>=fmt;
			tF.<span style="color: #000000;">antiAliasType</span> = AntiAliasType.<span style="color: #000000;">ADVANCED</span>;
			tF.<span style="color: #000000;">mouseEnabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			squContainer.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>tF<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> container:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>container<span style="color: #66cc66;">&#41;</span>;
			container.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #000000;">MOUSE_DOWN</span>, swapText, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			btn1 = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Button</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			btn1.<span style="color: #000000;">label</span> = <span style="color: #ff0000;">&quot;String 1&quot;</span>;
			container.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>btn1<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">name</span> = <span style="color: #ff0000;">&quot;btn1&quot;</span>;
&nbsp;
			btn2 = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Button</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			btn2.<span style="color: #000000;">label</span> = <span style="color: #ff0000;">&quot;String 2&quot;</span>;
			container.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>btn2<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">name</span> = <span style="color: #ff0000;">&quot;btn2&quot;</span>;
&nbsp;
			btn3 = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Button</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			btn3.<span style="color: #000000;">label</span> = <span style="color: #ff0000;">&quot;String 3&quot;</span>;
			container.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>btn3<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">name</span> = <span style="color: #ff0000;">&quot;btn3&quot;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> format<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			btn1.<span style="color: #000000;">y</span> = <span style="color: #cc66cc;">0</span>;
			btn2.<span style="color: #000000;">y</span> = <span style="color: #cc66cc;">24</span>;
			btn3.<span style="color: #000000;">y</span> = <span style="color: #cc66cc;">48</span>;
&nbsp;
			squContainer.<span style="color: #000000;">x</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #000000;">stageWidth</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> swapText<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;btn3&quot;</span>:
				textStr = <span style="color: #ff0000;">&quot;As we must account for every idle word, so must we account for every idle silence.&quot;</span>;
				squWidth = <span style="color: #cc66cc;">180</span>;
				squHeight = <span style="color: #cc66cc;">60</span>;
				<span style="color: #b1b100;">break</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;btn2&quot;</span>:
				textStr = <span style="color: #ff0000;">&quot;If you would not be forgotten as soon as you are dead, either write something worth reading or do things worth writing.&quot;</span>;
				squWidth = <span style="color: #cc66cc;">350</span>;
				squHeight = <span style="color: #cc66cc;">40</span>;
				<span style="color: #b1b100;">break</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;btn1&quot;</span>:
				textStr = <span style="color: #ff0000;">&quot;A great empire, like a great cake, is most easily diminished at the edges.&quot;</span>;
				squWidth = <span style="color: #cc66cc;">410</span>;
				squHeight = <span style="color: #cc66cc;">20</span>;
				<span style="color: #b1b100;">break</span>;
				<span style="color: #000000; font-weight: bold;">default</span>:
				<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			Tweener.<span style="color: #000000;">addTween</span><span style="color: #66cc66;">&#40;</span>squContainer, <span style="color: #66cc66;">&#123;</span>x:<span style="color: #0066CC;">stage</span>.<span style="color: #000000;">stageWidth</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span> - squWidth<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span> + <span style="color: #cc66cc;">50</span>, y:<span style="color: #0066CC;">stage</span>.<span style="color: #000000;">stageHeight</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span> - squHeight<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>, alpha:<span style="color: #cc66cc;">1</span>, <span style="color: #0066CC;">time</span>:<span style="color: #cc66cc;">1</span>, delay:<span style="color: #cc66cc;">0</span>, transition:<span style="color: #ff0000;">&quot;easeInOutQuart&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
			Tweener.<span style="color: #000000;">addTween</span><span style="color: #66cc66;">&#40;</span>square, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">width</span>:squWidth, <span style="color: #0066CC;">height</span>:squHeight, <span style="color: #0066CC;">time</span>:<span style="color: #cc66cc;">1</span>, delay:<span style="color: #cc66cc;">0</span>, transition:<span style="color: #ff0000;">&quot;easeInOutQuart&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
			Tweener.<span style="color: #000000;">addTween</span><span style="color: #66cc66;">&#40;</span>tF, <span style="color: #66cc66;">&#123;</span>_text:textStr, <span style="color: #0066CC;">width</span>:squWidth, <span style="color: #0066CC;">height</span>:squHeight, <span style="color: #0066CC;">time</span>:<span style="color: #cc66cc;">1</span>, delay:<span style="color: #cc66cc;">0</span>, transition:<span style="color: #ff0000;">&quot;easeInOutQuart&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://opentransmission.com/2010/01/tweener-text-swap-animation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bare Bones Flash MVC</title>
		<link>http://opentransmission.com/2010/01/flash-mvc-stripped/</link>
		<comments>http://opentransmission.com/2010/01/flash-mvc-stripped/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 23:11:20 +0000</pubDate>
		<dc:creator>Eric Cohen</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://escohen.com/?p=8</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_MVCExample_655525398"
			class="flashmovie"
			width="665"
			height="53">
	<param name="movie" value="http://www.opentransmission.com/shared/flash/MVCExample.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.opentransmission.com/shared/flash/MVCExample.swf"
			name="fm_MVCExample_655525398"
			width="665"
			height="53">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>It&#8217;s nice to have a simplified version of an MVC architecture to start a new project with. Those familiar with MVC (Model, View, Controller) know that it&#8217;s a very scalable architecture and a great way to separate your data from the visual assets of your site, then allow the controller to [...]]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_MVCExample_1790049824"
			class="flashmovie"
			width="665"
			height="53">
	<param name="movie" value="http://www.opentransmission.com/shared/flash/MVCExample.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.opentransmission.com/shared/flash/MVCExample.swf"
			name="fm_MVCExample_1790049824"
			width="665"
			height="53">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>It&#8217;s nice to have a simplified version of an MVC architecture to start a new project with. Those familiar with MVC (Model, View, Controller) know that it&#8217;s a very scalable architecture and a great way to separate your data from the visual assets of your site, then allow the controller to interface between the two. Those unfamiliar will enjoy how well it allows the data, logic and view to work with each other in an encapsulated way. <span id="more-8"></span><br />
<br />
The framework operates in a cyclical way: View > Controller > Model > View.<br />
Here, the View has an event listener waiting for a button to be clicked. This listener calls a function in the controller. Depending on the logic in the controller, the method sends a property to the Model. Upon receiving that property the Model dispatches an event that the View is listening for. The View then initiates an action.<br />
<br />
In this example, buttons, the text box and the red bar exist in the View. The event listener in the View waits for a button to be clicked and then executes a method in the Contoller. The Controller performs simple logic with the data it&#8217;s received. Here it tests if the number is between 0 and 10. If is does, then set a property in the Model. The Model then dispatches an event that the View is listening for. The View executes code which changes the width of the bar.<br />
<br />
<a class="download" href="http://www.opentransmission.com/downloads/MVCExample.zip", target"_blank"><b>Download Source</b></a></p>
<h5>Main.as</h5>

<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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> mvc.<span style="color: #66cc66;">*</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _model:Model;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _controller:Controller;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _view:View;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			_model=<span style="color: #000000; font-weight: bold;">new</span> Model<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_controller=<span style="color: #000000; font-weight: bold;">new</span> Controller<span style="color: #66cc66;">&#40;</span>_model<span style="color: #66cc66;">&#41;</span>;
			_view=<span style="color: #000000; font-weight: bold;">new</span> View<span style="color: #66cc66;">&#40;</span>_model,_controller<span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>_view<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h5> Model.as</h5>

<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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package mvc
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">EventDispatcher</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Model <span style="color: #0066CC;">extends</span> EventDispatcher
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> UPDATE:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">'modelWasUpdated'</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _number:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Model<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">number</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _number;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">number</span><span style="color: #66cc66;">&#40;</span>n:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
			_number=n;
			dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span>Model.<span style="color: #000000;">UPDATE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h5> View.as</h5>

<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="actionscript" style="font-family:monospace;">package mvc
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">MouseEvent</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">controls</span>.<span style="color: #0066CC;">Button</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">controls</span>.<span style="color: #000000;">TextArea</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> View <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _model:Model;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _controller:Controller;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> btnUp:<span style="color: #0066CC;">Button</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> btnDown:<span style="color: #0066CC;">Button</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> textArea:TextArea;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bar:Bar;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> View<span style="color: #66cc66;">&#40;</span>model:Model,controller:Controller<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			_model=model;
			_controller=controller;
			_model.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Model.<span style="color: #000000;">UPDATE</span>,update<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			positionAndFormat<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> container:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>container<span style="color: #66cc66;">&#41;</span>;
			container.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #000000;">MOUSE_DOWN</span>, _controller.<span style="color: #000000;">numberUpdate</span>, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			btnUp = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Button</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			container.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>btnUp<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">name</span> = <span style="color: #ff0000;">&quot;numUp&quot;</span>;
&nbsp;
			btnDown = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Button</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			container.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span>btnDown<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">name</span> = <span style="color: #ff0000;">&quot;numDown&quot;</span>;
&nbsp;
			textArea = <span style="color: #000000; font-weight: bold;">new</span> TextArea<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>textArea<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			bar = <span style="color: #000000; font-weight: bold;">new</span> Bar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>bar<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> positionAndFormat<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			btnUp.<span style="color: #000000;">x</span> = <span style="color: #cc66cc;">0</span>;
			btnUp.<span style="color: #000000;">label</span> = <span style="color: #ff0000;">&quot;Number Up&quot;</span>;
&nbsp;
			btnDown.<span style="color: #000000;">x</span> = <span style="color: #cc66cc;">110</span>;
			btnDown.<span style="color: #000000;">label</span> = <span style="color: #ff0000;">&quot;Number Down&quot;</span>;
&nbsp;
			textArea.<span style="color: #000000;">y</span> = <span style="color: #cc66cc;">30</span>;
			textArea.<span style="color: #0066CC;">width</span> = textArea.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">22</span>;
			textArea.<span style="color: #0066CC;">text</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>_model.<span style="color: #0066CC;">number</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			bar.<span style="color: #000000;">x</span> = <span style="color: #cc66cc;">28</span>;
			bar.<span style="color: #000000;">y</span> = textArea.<span style="color: #000000;">y</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			textArea.<span style="color: #0066CC;">text</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>_model.<span style="color: #0066CC;">number</span><span style="color: #66cc66;">&#41;</span>;
			bar.<span style="color: #000000;">update</span><span style="color: #66cc66;">&#40;</span>_model.<span style="color: #0066CC;">number</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h5> Controller.as</h5>

<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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package mvc
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">MouseEvent</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Controller
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _model:Model;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Controller<span style="color: #66cc66;">&#40;</span>model:Model<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			_model=model;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> numberUpdate<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;numUp&quot;</span>:
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_model.<span style="color: #0066CC;">number</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> _model.<span style="color: #0066CC;">number</span>++;
				<span style="color: #b1b100;">break</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;numDown&quot;</span>:
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_model.<span style="color: #0066CC;">number</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> _model.<span style="color: #000000;">number</span>--;
				<span style="color: #b1b100;">break</span>;
				<span style="color: #000000; font-weight: bold;">default</span>:
				<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h5> Bar.as</h5>

<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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">transitions</span>.<span style="color: #000000;">Tween</span>;
 	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">transitions</span>.<span style="color: #000000;">easing</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Bar <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> square:Sprite;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Bar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			square = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>square<span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xff0000, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #000000;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">22</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #000000;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span>num:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> scaleTween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span>square, <span style="color: #ff0000;">&quot;width&quot;</span>, Regular.<span style="color: #000000;">easeOut</span>, square.<span style="color: #0066CC;">width</span>, num <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">65</span>, .5, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
			square.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://opentransmission.com/2010/01/flash-mvc-stripped/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add/Subtract Items from an Array</title>
		<link>http://opentransmission.com/2010/01/add-subtract-items-from-an-array/</link>
		<comments>http://opentransmission.com/2010/01/add-subtract-items-from-an-array/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 21:31:48 +0000</pubDate>
		<dc:creator>Eric Cohen</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://escohen.com/?p=1</guid>
		<description><![CDATA[This is it.]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ArrayExample_1885197103"
			class="flashmovie"
			width="665"
			height="75">
	<param name="movie" value="http://www.opentransmission.com/shared/flash/ArrayExample.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.opentransmission.com/shared/flash/ArrayExample.swf"
			name="fm_ArrayExample_1885197103"
			width="665"
			height="75">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>Here is something I used for a sorting/filtering application. I needed a way to add and remove items from an array and have the button know whether or not it had been added. When a button is clicked, the event handler sends a boolean property to the clicked button setting it as added or not added. Because the button stores that property, when you click the button it can toggle it&#8217;s properties in and out of the array based on whether or not it has been added.  <span id="more-1"></span><br />
<br />
The basic flow is as follows. Create buttons based on an array and position them. Here our &#8220;_itemsArr&#8221; has five items. Set up an event listener for the buttons and store the boolean property in the button and update it when it has been clicked. Depending on whether the property is true or false, add or subtract that button&#8217;s label property to an array while updating the text area with the array.<br />
<br />
<a class="download" href="http://www.opentransmission.com/downloads/ArrayExample.zip", target"_blank"><b>Download Source</b></a></p>
<h5>ArrayExample.as</h5>

<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
81
82
83
84
85
86
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">display</span>.<span style="color: #000000;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #000000;">events</span>.<span style="color: #000000;">MouseEvent</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">controls</span>.<span style="color: #000000;">TextArea</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ArrayExample <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> buttonOffset:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">141</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _itemsArr:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Earth&quot;</span>, <span style="color: #ff0000;">&quot;Fire&quot;</span>, <span style="color: #ff0000;">&quot;Wind&quot;</span>, <span style="color: #ff0000;">&quot;Water&quot;</span>, <span style="color: #ff0000;">&quot;Chicken&quot;</span><span style="color: #66cc66;">&#93;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _activeItemArr:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> container:Sprite;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> traceArea:TextArea;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">button</span>:ButtonClass;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ArrayExample<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			buildDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			positionDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> buildDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			container = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>container<span style="color: #66cc66;">&#41;</span>;
			container.<span style="color: #000000;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #000000;">MOUSE_DOWN</span>, buttonHandler<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> buttonPosition:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
			<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> _itemsArr.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">button</span> = <span style="color: #000000; font-weight: bold;">new</span> ButtonClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				container.<span style="color: #000000;">addChild</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">button</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #0066CC;">button</span>.<span style="color: #000000;">label</span> = _itemsArr<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
				<span style="color: #0066CC;">button</span>.<span style="color: #000000;">x</span> = buttonPosition;
				buttonPosition += buttonOffset;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			traceArea = <span style="color: #000000; font-weight: bold;">new</span> TextArea<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>traceArea<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> positionDisplay<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			traceArea.<span style="color: #000000;">x</span> = container.<span style="color: #000000;">x</span>;
			traceArea.<span style="color: #000000;">y</span> = container.<span style="color: #000000;">y</span> + <span style="color: #cc66cc;">30</span>;
			traceArea.<span style="color: #0066CC;">width</span> = container.<span style="color: #0066CC;">width</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> buttonHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> activeItem:ButtonClass = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as ButtonClass;
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>activeItem.<span style="color: #000000;">added</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				addToArray<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #000000;">label</span><span style="color: #66cc66;">&#41;</span>;
				activeItem.<span style="color: #000000;">added</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span> 
				removeFromArray<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #000000;">label</span><span style="color: #66cc66;">&#41;</span>;
				activeItem.<span style="color: #000000;">added</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			traceArea.<span style="color: #0066CC;">text</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>_activeItemArr<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> addToArray<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> dupNumber:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
			_activeItemArr.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> _activeItemArr.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_activeItemArr<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> == <span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#41;</span> dupNumber++;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dupNumber <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> _activeItemArr.<span style="color: #0066CC;">pop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> removeFromArray<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> _activeItemArr.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_activeItemArr<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> == <span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#41;</span> _activeItemArr.<span style="color: #0066CC;">splice</span><span style="color: #66cc66;">&#40;</span>i,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h5>ButtonClass.as</h5>

<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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> fl.<span style="color: #000000;">controls</span>.<span style="color: #0066CC;">Button</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ButtonClass <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">Button</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _added:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> added<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _added;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> added<span style="color: #66cc66;">&#40;</span>added:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_added = added;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ButtonClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://opentransmission.com/2010/01/add-subtract-items-from-an-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
