<?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>indieas &#187; button</title>
	<atom:link href="http://www.indieas.org/tag/button/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indieas.org</link>
	<description>independent actionscript developer team</description>
	<lastBuildDate>Tue, 19 Oct 2010 13:43:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Buttons the indieas way</title>
		<link>http://www.indieas.org/2010/08/buttons-the-indieas-way/</link>
		<comments>http://www.indieas.org/2010/08/buttons-the-indieas-way/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 22:39:54 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[down]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[over]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[simplebutton]]></category>
		<category><![CDATA[state]]></category>
		<category><![CDATA[tween]]></category>
		<category><![CDATA[up]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=187</guid>
		<description><![CDATA[As announced I optimized the usage of Buttons in the indieas library. SimpleButton with disabled state So the first I create a MovieClip with the different states: As you can see there is an additional disabled state compared to the normal SimpleButton. So one way to use this MovieClip now as a Button in my [...]]]></description>
			<content:encoded><![CDATA[<p>As announced I optimized the usage of Buttons in the <a href="http://www.indieas.org/library/" target="_self">indieas library</a>.</p>
<p><strong>SimpleButton with disabled state</strong></p>
<p><strong> </strong>So the first I create a MovieClip with the different states:</p>
<p><a href="http://www.indieas.org/wp-content/uploads/2010/08/states.png"><img class="alignnone size-full wp-image-188" title="states" src="http://www.indieas.org/wp-content/uploads/2010/08/states.png" alt="" width="359" height="132" /></a></p>
<p>As you can see there is an additional <em>disabled </em>state compared to the normal SimpleButton. So one way to use this MovieClip now as a Button in my Actionscript project is to export it as a Class:</p>
<p><a href="http://www.indieas.org/wp-content/uploads/2010/08/export.png"><img class="alignnone size-full wp-image-189" title="export" src="http://www.indieas.org/wp-content/uploads/2010/08/export.png" alt="" width="536" height="160" /></a></p>
<p>Now when I use the exported swc file as a library in my Actionscript project I can easily create a Button like that:</p>
<pre class="brush: as3; title: ; notranslate">
var but:Button = Button.FromClass( DemoButton );
but.enable = false; // to jump to the disabled state.
addChild( but );
</pre>
<p>Another way to create a Button is to turn an already placed DemoButton MovieClip into a Button. So you don&#8217;t have to add it as a Child and it just turns it into a Button instance:</p>
<pre class="brush: as3; title: ; notranslate">
var but:Button = Button.FromMC( myDemoButton ); // where myDemoButton is an instance of the DemoButton
</pre>
<p><strong>Adding scripting animations</strong></p>
<p>This is the simplest usage but more often I like to add scripting animations on mouse events. So for example you have an icon on the button that should pop-up on roll-over. The Button class provides an easy way to access MovieClips placed on the timeline. So lets enhance the DemoButton with an icon:</p>
<p><a href="http://www.indieas.org/wp-content/uploads/2010/08/icon.png"><img class="alignnone size-medium wp-image-199" title="icon" src="http://www.indieas.org/wp-content/uploads/2010/08/icon-300x175.png" alt="" width="300" height="175" /></a></p>
<p>As this Button is special we create an IconButton class:</p>
<pre class="brush: as3; title: ; notranslate">
package {

	import org.indieas.tween.easing.Bounce;
	import org.indieas.tween.easing.Elastic;
	import org.indieas.tween.property.Scaler;
	import org.indieas.widget.button.Button;

	public class IconButton extends Button {

		public function IconButton() {
			super();
		}

		protected override function onOver():void {
			Scaler.To( stateManager.icon, 0.7, 1.5, 1.5, Elastic.easeOut ).start();
		}

		protected override function onUp():void {
			Scaler.To( stateManager.icon, 0.3, 1, 1, Bounce.easeOut ).start();
		}
	}
}
</pre>
<p>The animation is now done by the indieas tween engine, but you can use any tweening engine you like. The stateManager handles the access to the icon MovieClip that we placed earlier.</p>
<p>To instantiate the IconButton we can again do it with a MovieClip or the class:</p>
<pre class="brush: as3; title: ; notranslate">
var but:IconButton = new IconButton();

but.buildFromClass( DemoButton );
addChild( but );

// or
but.buildFromMC( myDemoButton );
</pre>
<p>This results in a button like this:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ButtonTest_2017138603"
			class="flashmovie"
			width="150"
			height="50">
	<param name="movie" value="http://www.indieas.org/wp-content/uploads/2010/08/ButtonTest.swf" />
	<param name="bgcolor" value="#FFFFFF" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.indieas.org/wp-content/uploads/2010/08/ButtonTest.swf"
			name="fm_ButtonTest_2017138603"
			width="150"
			height="50">
		<param name="bgcolor" value="#FFFFFF" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>One big advantage of this approach is that you can have different MovieClips with other assets that uses the same Button class. For example to create another IconButton that just looks different you can call the<em> buildFrom* </em>method with another MovieClip/Class.</p>
<p><strong>Buttons with labels</strong></p>
<p>There is another handy class called LabelButton, where you place a TextField into the Button called <em>label</em>. You have now methods where you can style the Text with CSS. For example:</p>
<pre class="brush: as3; title: ; notranslate">
var label:LabelButton = LabelButton.FromMC( draft.labelButton );
label.setStyle( upFormat ); // set the style for all states.
label.setStyle( overFormat, Button.OVER_STATE ); // specific style for over state.
label.embedFont = true;
label.antiAliasType = AntiAliasType.ADVANCED;
label.gridFitType = GridFitType.SUBPIXEL;
</pre>
<p>So thats it, if you like to use these classes too,  go to the <a href="http://www.indieas.org/library/" target="_self">libary page</a> and download the latest classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2010/08/buttons-the-indieas-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Summer cleaning</title>
		<link>http://www.indieas.org/2010/08/summer-cleaning/</link>
		<comments>http://www.indieas.org/2010/08/summer-cleaning/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 16:51:45 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[disabled]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[labels]]></category>
		<category><![CDATA[simplebutton]]></category>
		<category><![CDATA[state]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=183</guid>
		<description><![CDATA[Its been a while since I was working / improving the indieas library. But as I lately had a new idea to improve my workflow I realized, that i should clean up the library and fix the upload script again so that you can download the latest version again. Thats now all fixed. So make [...]]]></description>
			<content:encoded><![CDATA[<p>Its been a while since I was working / improving the indieas library. But as I lately had a new idea to improve my workflow I realized, that i should clean up the library and fix the upload script again so that you can download the latest version again.</p>
<p>Thats now all fixed. So make sure you test out the latest revision.</p>
<p>Furthermore I give you small <strong>preview</strong> on what I&#8217;m working at the moment. My actual problem where <strong>Buttons</strong>. Yes, it sounds too simple &#8211; but i was never really satisfied with my solutions. I actually like the SimpleButtons with the framelabels &#8211; but there is <strong>no way to extend them or add a disabled state</strong>. So thats useless in 70% of my use. Thats why I came up with a solution where I <strong>easily can create a Button in Flash with frame labels </strong>but also<strong> can simply extend them to control animations by script</strong>.</p>
<p>So soon there will be a post about how I work with Buttons in Flash and Flash Builder.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2010/08/summer-cleaning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>skinnable widgets without flex</title>
		<link>http://www.indieas.org/2009/09/skinnable-widgets-without-flex/</link>
		<comments>http://www.indieas.org/2009/09/skinnable-widgets-without-flex/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 14:45:37 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[dropdown]]></category>
		<category><![CDATA[library widgets]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[scrollpane]]></category>
		<category><![CDATA[textarea]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=53</guid>
		<description><![CDATA[In my current project I had to implement a bunch of the standard widgets or components. As you maybe already noticed by this entry I spent a bit more time to implement the widgets that I can use them in multiple projects. In the end I had the most common widgets like: Button, CheckBox, DropDown, [...]]]></description>
			<content:encoded><![CDATA[<p>In my current project I had to implement a bunch of the standard widgets or components. As you maybe already noticed by <a href="http://www.indieas.org/2009/09/reinvent-the-wheel-or-how-to-program-a-button-in-as3/" target="_blank">this</a> entry I spent a bit more time to implement the widgets that I can use them in multiple projects. In the end I had the most common widgets like: Button, CheckBox, DropDown, Vertical- and HorizontalList, ScrollPane/Pane and TextArea.</p>
<p>The advantage of these widgets are:</p>
<ul>
<li>skin-able with flash like a flex component</li>
<li>support for CSS</li>
<li>small footprint</li>
<li>usable in non-flex projects</li>
<li>tight integration with <a href="http://modular.sandkasten.ch/" target="_blank">modular</a></li>
</ul>
<p>Check out the links section to download the indieas library.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/09/skinnable-widgets-without-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reinvent the wheel or how to program a button in AS3</title>
		<link>http://www.indieas.org/2009/09/reinvent-the-wheel-or-how-to-program-a-button-in-as3/</link>
		<comments>http://www.indieas.org/2009/09/reinvent-the-wheel-or-how-to-program-a-button-in-as3/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 12:15:07 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[states]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=47</guid>
		<description><![CDATA[Something that you learn at the very beginning of developing flash projects is how to create a button. There is this practical Button symbol where you can define the common up, over and down states of a button. This is great but has two major downsides: you can not change anything at runtime like a [...]]]></description>
			<content:encoded><![CDATA[<p>Something that you learn at the very beginning of developing flash projects is how to create a button. There is this practical Button symbol where you can define the common up, over and down states of a button. This is great but has two major downsides:</p>
<ol>
<li>you can not change anything at runtime like a label.</li>
<li>there is no disabled state.</li>
</ol>
<p>So I started to find a way to solve this. After a day playing around I came up with the following solution;</p>
<p>As it needs different states I was looking for a solution to encapsulate these states behind a single class and the StateManager was born. I setup the StateManager first with all the different states:</p>
<pre class="brush: as3; title: ; notranslate">
stateManager = new StateManager();
stateManager.addState( &quot;up&quot;, ButtonUpDraft ); stateManager.addState( &quot;down&quot;, ButtonDownDraft );
stateManager.addState( &quot;over&quot;, ButtonOverDraft );
</pre>
<p>ButtonUpDraft, ButtonDownDraft, ButtonOverDraft are simple MovieClips exported from Flash that are instantiate inside the StateManager. Each one of these MovieClips contain a MovieClip called &#8220;bg&#8221; and a TextField called &#8220;label&#8221;. So to adjust for example the width of the &#8220;bg&#8221; on every state I can call:</p>
<pre class="brush: as3; title: ; notranslate">stateManager.bg.width = 230;</pre>
<p>To change the current state I simply can call:</p>
<pre class="brush: as3; title: ; notranslate">stateManager.state = &quot;up&quot;;</pre>
<p>This way my Button class has not to deal with the individual states and can adjust properties of state assets over multiple states with one command. So my final Button class looks something like this:</p>
<pre class="brush: as3; title: ; notranslate">
package org.indieas.widgets {
 import flash.events.MouseEvent;
 import flash.text.AntiAliasType;
 import flash.text.TextFieldAutoSize;

 import org.indieas.theme.ButtonDisableDraft;
 import org.indieas.theme.ButtonDownDraft;
 import org.indieas.theme.ButtonOverDraft;
 import org.indieas.theme.ButtonUpDraft;
 import org.indieas.widgets.states.AbstractStatesWidget;

 public class Button extends AbstractStatesWidget {

 private var deltaWidth:Number;
 private var _resizeByLabel:Boolean = false;

 public function Button() {
 super();

 stateManager.state = &quot;up&quot;;

 deltaWidth = stateManager.bg.width - stateManager.label.width;

 stateManager.label.autoSize = TextFieldAutoSize.LEFT;
 stateManager.label.multiline = false;
 stateManager.label.wordWrap = false;
 stateManager.label.mouseEnabled = false;

 addEventListener( MouseEvent.MOUSE_UP, onUp );
 addEventListener( MouseEvent.MOUSE_OVER, onOver );
 addEventListener( MouseEvent.MOUSE_OUT, onOut );
 addEventListener( MouseEvent.MOUSE_DOWN, onDown );

 useHandCursor = buttonMode = true;
 }

 protected override function initStates():void {
 stateManager.addState( &quot;up&quot;, ButtonUpDraft );
 stateManager.addState( &quot;over&quot;, ButtonOverDraft );
 stateManager.addState( &quot;down&quot;, ButtonDownDraft );
 stateManager.addState( &quot;disable&quot;, ButtonDisableDraft );
 }

 public function set label( value:String ):void {
 stateManager.label.text = value;
 if( _resizeByLabel ) {
 width = stateManager.label.width + deltaWidth;
 } else {
 width = stateManager.bg.width;
 }
 }

 public function get label():String {
 return stateManager.label.text;
 }

 public function set enable( value:Boolean ):void {
 mouseEnabled = mouseChildren = value;
 if( value ) {
 stateManager.state = &quot;up&quot;;
 } else {
 stateManager.state = &quot;disable&quot;;
 }
 }

 public function get enable():Boolean {
 return stateManager.state != &quot;disable&quot;;
 }

 public override function set width(value:Number):void {
 stateManager.bg.width = value;
 stateManager.label.x = ( value - stateManager.label.width ) / 2;
 }

 public override function set height(value:Number):void {
 stateManager.bg.height = value;
 stateManager.label.y = ( ( value - stateManager.label.height ) / 2 ) + 1;
 }

 private function onUp( me:MouseEvent ):void {
 stateManager.state = &quot;over&quot;;
 }
 private function onOver( me:MouseEvent ):void {
 stateManager.state = &quot;over&quot;;
 }
 private function onOut( me:MouseEvent ):void {
 if( enable ) stateManager.state = &quot;up&quot;;
 }
 private function onDown( me:MouseEvent ):void {
 stateManager.state = &quot;down&quot;;
 }
 }
}
</pre>
<p>The advantage is obvious as there is no big mess with different states and you can focus only on the functionality of the button. So at the end of the day a friend, how had nothing to do with as, asked me what i was doing today. My answer was in a way disappointing as I said I just programmed a button&#8230; the whole day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/09/reinvent-the-wheel-or-how-to-program-a-button-in-as3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

