<?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; Articles</title>
	<atom:link href="http://www.indieas.org/category/articles/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>Stop Motion app</title>
		<link>http://www.indieas.org/2010/10/stop-motion-app/</link>
		<comments>http://www.indieas.org/2010/10/stop-motion-app/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 16:12:52 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[nativeprocess]]></category>
		<category><![CDATA[stopmotion]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=209</guid>
		<description><![CDATA[Recently we were talking about stop motion animations when I though, that should be pretty easy to do in flash. So I gave it a try  to see how far I get in one evening. Accessing the cam and taking snapshot is easy so I made a simple array of images and played through them [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we were talking about stop motion animations when I though, that should be pretty easy to do in flash. So I gave it a try  to see how far I get in one evening. Accessing the cam and taking snapshot is easy so I made a simple array of images and played through them with the timer. Result:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_StopMotion_521111942"
			class="flashmovie"
			width="650"
			height="614">
	<param name="movie" value="http://www.indieas.org/wp-content/uploads/2010/10/StopMotion.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.indieas.org/wp-content/uploads/2010/10/StopMotion.swf"
			name="fm_StopMotion_521111942"
			width="650"
			height="614">
	<!--<![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>You can also flip through the images by sliding over the image region. To delete the image when flipping through simply click.</p>
<p>Now thats good and nice but you can&#8217;t save. Even better would be a rendered mpeg movie as a final result. To do so I used the new AIR 2.0 NativProcess to call <a href="http://www.ffmpeg.org" target="_blank">ffmpeg</a> that turns a serie of images into a movie. The images are stored in a tmp directory using the PNGExporter. Voila finished is the StopMotion application that can render images to a mpeg movie.</p>
<p>I like the new NativeProcess as it allows to break out of the AIR container and runs other apps. So if somebody wants to play around with the StopMotion app feel free to download it:</p>
<p><a href="http://www.indieas.org/wp-content/uploads/2010/10/StopMotion.dmg" target="_blank">AIR StopMotion (DMG)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2010/10/stop-motion-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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_342055149"
			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_342055149"
			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>to be open source or not &#8211; thats the question</title>
		<link>http://www.indieas.org/2009/12/to-be-open-source-or-not-thats-the-question/</link>
		<comments>http://www.indieas.org/2009/12/to-be-open-source-or-not-thats-the-question/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 13:25:46 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[donation]]></category>
		<category><![CDATA[license]]></category>
		<category><![CDATA[modular]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=167</guid>
		<description><![CDATA[In the last weeks I was thinking about open sourcing my modular framework. So far I kept it closed source and got some money if somebody used it in commercial projects. But I&#8217;m not very happy with this solution as it costs quite an effort to use a commercial framework. That why I though it [...]]]></description>
			<content:encoded><![CDATA[<p>In the last weeks I was thinking about <strong>open sourcing</strong> my <a href="http://modular.sandkasten.ch" target="_blank">modular framework</a>. So far I kept it closed source and got some money if somebody used it in commercial projects. But I&#8217;m not very happy with this solution as it costs quite an effort to use a commercial framework.</p>
<p>That why I though it would be better to distribute it for free and open source.  My <strong>major problem</strong> is that I spent many hours in developing modular and earning some money to redeem would be great. So to help me making a decision I made my own list of advantages for going open source;</p>
<p>Advantages:</p>
<ul>
<li>everybody can use it for free.</li>
<li>can use open source platforms for advertising.</li>
<li>other programmers may join the development.</li>
<li>higher possibility for viral marketing without to much effort.</li>
<li>same level with other open source frameworks. No &#8220;why should I paid for this&#8221; questions.</li>
<li>?maybe? get some money by donations</li>
<li>possibility to sell commercial modules to companies.</li>
</ul>
<p>I&#8217;m wondering if there is somebody with experience with donations? Does this really work? Or maybe other inputs for changing to open source? Just let me know&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/12/to-be-open-source-or-not-thats-the-question/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Onscreen Keyboard with AIR</title>
		<link>http://www.indieas.org/2009/11/onscreen-keyboard-with-air/</link>
		<comments>http://www.indieas.org/2009/11/onscreen-keyboard-with-air/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 18:20:20 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[htmlloader]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[onscreen]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[textarea]]></category>
		<category><![CDATA[textfield]]></category>
		<category><![CDATA[touchschreen]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=158</guid>
		<description><![CDATA[In one of my last projects I had to develop an air application with an onscreen keyboard that is working with flash as with the internal html browser of air. I realized pretty quickly that this isn&#8217;t that easy as it seams. There are multiple problems especially with the html view: how do i get [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my last projects I had to develop an air application with an <strong>onscreen keyboard</strong> that is working with <strong>flash</strong> as with the <strong>internal html browser</strong> of air.</p>
<p>I realized pretty quickly that this isn&#8217;t that easy as it seams. There are multiple problems especially with the html view:</p>
<ul>
<li>how do i get the focus in the html view to add letters.</li>
<li>how do i get the selection to add chars on the right position.</li>
<li>how do i know when a user clicks and inputfield/textarea.</li>
<li>how do i prevent that flash do set the focus on the keyboard when I click on a letter sprite.</li>
</ul>
<p>After some experiments I discovered the really nice javascript support of the internal browser. So my first problem was already gone, when I found the javascript command:</p>
<pre class="brush: as3; title: ; notranslate">
var webView:HTMLLoader = new HTMLLoader();
//...later, to get the element with the focus call:
var element:Object = webView.window.document.activeElement;
</pre>
<p>I wasn&#8217;t really into javascript so I was surprised to discover even more possibilities. Now with the focus I can place an onscreen keyboard made with flash and get the activeElement of the htmlloader and add characters to it. something like this:</p>
<pre class="brush: as3; title: ; notranslate">
var inputField:Object = webView.window.document.activeElement;
if( inputField != null ) {
   var select:Number = addScreenBoardText( e.char, inputField, &quot;value&quot;, &quot;selectionStart&quot;, &quot;selectionEnd&quot; );
   inputField.setSelectionRange( select, select );
}
</pre>
<p>The function where I add the char and return the selection where the cursor should be set:</p>
<pre class="brush: as3; title: ; notranslate">
private function addScreenBoardText( insert:String, object:Object, textAttribute:String, selectionStartAttribute:String, selectionEndAttribute:String ):Number {
  var selectionStart:Number = object[ selectionStartAttribute ];
  var selectionEnd:Number = object[ selectionEndAttribute ];
  var original:String = object[ textAttribute ];
  var newText:String = original.substring( 0, selectionStart ) + insert + original.substr( selectionEnd );
  object[ textAttribute ] = newText;
  return selectionStart + insert.length;
}
</pre>
<p>Why I make this weird looking function is because I can use it also for the flash TextField just with different parameters. So now we can add letters to a textfield in a html view as a flash TextField. But one big problem is that we loose the focus every time we click on our on screen keyboard. And there is a way to prevent the change of the focus which is very handy in this situation:</p>
<pre class="brush: as3; title: ; notranslate"> // in our main application class we listen to the mouse focus change event.
addEventListener( FocusEvent.MOUSE_FOCUS_CHANGE, onMouseFocus );

// in the listener we check if the relatedObject is a Key,Screenboard ( these are my classes for the Keyboard that get mouseclicks )
// then we prevent the default behaviour of the event. which means no focus change is triggered.
private function onMouseFocus( fe:FocusEvent ):void {
if( fe.relatedObject is Key || fe.relatedObject is ScreenBoard ) fe.preventDefault();
}
</pre>
<p>We saw earlier that is was possible to write to javascript objects as normal in actionscript. I was even more surprised as its possible to listen to javascript events with actionscript functions. That allows me to listen to javascript focus changes and hide/show the keyboard. This way I can make an overlay keyboard that is only visible when I click in a textfield which I find is a very nice solution. So this is how I listened to the javascript events ( keep in mind that this is all actionscript ):</p>
<pre class="brush: as3; title: ; notranslate">
// register everytime the page has loaded!
private function onPageLoaded( e:Event ):void {
  webView.window.addEventListener( &quot;focus&quot;, onJavaScriptFocusIn, true );
  webView.window.addEventListener( &quot;blur&quot;, onJavaScriptFocusOut, true );
 }

// if we get a focus in event from js, check if its a inputfield or a textarea. then show the keyboard.
private function onJavaScriptFocusIn( e:Object ):void {
  if( e.target.localName == &quot;input&quot; || e.target.localName == &quot;textarea&quot; ) {
    dispatchEvent( new JavaScriptEvent( JavaScriptEvent.FOCUS_IN ) );
  }
}

// we lost focus - hide keyboard
private function onJavaScriptFocusOut( e:Object ):void {
  dispatchEvent( new JavaScriptEvent( JavaScriptEvent.FOCUS_OUT ) );
}
</pre>
<p>With all this you can build your onscreen keyboard that is working in <strong>flash as in html</strong>. I made a<a href="http://www.indieas.org/wp-content/uploads/2009/11/screenboard.zip"> quick flexbuilder air project</a> that you can download with a keyboard, textfield and htmlloader.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/11/onscreen-keyboard-with-air/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Dynamic XML definitions</title>
		<link>http://www.indieas.org/2009/10/dynamic-xml-definitions/</link>
		<comments>http://www.indieas.org/2009/10/dynamic-xml-definitions/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 21:07:41 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=110</guid>
		<description><![CDATA[Something that I haven&#8217;t noticed for a long time are dynamic xml definitions. What it is; Its a very easy way to construct xml with dynamic content. Here is a short example: The {} braces are replaced by the variable value. You can also place more complex stuff inside these curly braces. Here is another [...]]]></description>
			<content:encoded><![CDATA[<p>Something that I haven&#8217;t noticed for a long time are dynamic xml definitions. What it is; Its a very easy way to construct xml with dynamic content. Here is a short example:</p>
<pre class="brush: as3; title: ; notranslate">
var nodeValue:String = &quot;bis naii&quot;;
var attributeValue:String = &quot;mich&quot;;
var xml:XML = &lt;speech speaker={attributeValue}&gt;{nodeValue}&lt;/speech&gt;;
trace( xml ); // &lt;speech speaker=&quot;mich&quot;&gt;bis naii&lt;/speech&gt;
</pre>
<p>The {} braces are replaced by the variable value. You can also place more complex stuff inside these curly braces. Here is another example:</p>
<pre class="brush: as3; title: ; notranslate">
var xml:XML = &lt;root /&gt;
for ( var i:Number = 0; i &lt; 3; i++ ) {
    xml.appendChild( &lt;child&gt;{&quot;content: &quot; + ( i + 1 )}&lt;/child&gt; );
}
/**
 * gives:
 * &lt;root&gt;
 * &lt;child&gt;content: 1&lt;/child&gt;
 * &lt;child&gt;content: 2&lt;/child&gt;
 * &lt;child&gt;content: 3&lt;/child&gt;
 * &lt;/root&gt;
 */
</pre>
<p>In some situations this way of constructing an xml structure is very practical&#8230;.</p>
<p>For more infos check <a href="http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4">senocular&#8217;s page</a> about XML</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/10/dynamic-xml-definitions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error #2148 or how to access local and network resources</title>
		<link>http://www.indieas.org/2009/09/error-2148-or-how-to-access-local-and-network-resources/</link>
		<comments>http://www.indieas.org/2009/09/error-2148-or-how-to-access-local-and-network-resources/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 10:24:57 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=97</guid>
		<description><![CDATA[I bet you all got already the Error #2148 when developing. In my case this happens often when I am developing an application where some resources are local and some are already from a backend server. For example I have a local config.xml just right next to my swf application and some other data from [...]]]></description>
			<content:encoded><![CDATA[<p>I bet you all got already the Error #2148 when developing. In my case this happens often when I am developing an application where some resources are local and some are already from a backend server. For example I have a <strong>local config.xml</strong> just right next to my swf application <strong>and</strong> some<strong> other data from a backend server somewhere on another domain</strong>.</p>
<p>Now this is a problem as you can either publish your swf with <strong>local-security sandbox</strong> or <strong>network-security sandbox</strong> but in my case I need both as I have local resources and network resources. So I go through both ways;</p>
<p><strong>local-security sandbox way</strong></p>
<p><img class="size-full wp-image-99 alignnone" title="Adobe Flash Player has stopped a potentially unsafe operation." src="http://www.indieas.org/wp-content/uploads/2009/09/local-sandbox-popup.png" alt="local-sandbox-popup" width="584" height="276" /></p>
<p>I can access my config.xml but when I try to load the data from another domain the following popup shows up:</p>
<p>In the <a href="http://www.macromedia.com/support/documentation/de/flashplayer/help/settings_manager04.html">Security Settings Manager</a> that opens when you click <em>Settings&#8230; </em>you can add the remote domain and restart the browser then the swf should be able to access this domain. But I personally prefere the network-security sandbox way:</p>
<p><strong>network-security sandbox way</strong></p>
<p>Here you publish your swf with the network-security sandbox by adding the <strong>-use-network=true</strong> to the flex compiler or setting the <em>Local playback security</em> to <strong>Access network only</strong> in the Flash CS4 publish settings. This way your swf can access any domains from the internet. So in my case no problem to load the data from my backend server. But when load my local config.xml I get the following error:</p>
<p><em>Error #2148: SWF file file:///demo.swf cannot access local resource config.xml. Only local-with-filesystem and trusted local SWF files may access local resources.</em></p>
<p>The fastest solution to get rid of this error you go to the <a href="http://www.macromedia.com/support/documentation/de/flashplayer/help/settings_manager04.html">Security Settings Manager</a> and add a new location for mac: <strong>/</strong> and for pc: <strong>c:/</strong></p>
<p><strong></strong><img class="alignnone size-full wp-image-100" title="security_settings" src="http://www.indieas.org/wp-content/uploads/2009/09/security_settings.png" alt="security_settings" width="399" height="275" /></p>
<p>The Security Settings Manager is a bit buggy. So restart your browser and check again if its really saved. Finally this entry allows the swf file to read local files. Here you allow full access to your machine which can be a <strong>security problem</strong>. It&#8217;s <strong>better</strong> to specify the <strong>root folder</strong> of your flash/flex projects. This way all your projects swf are trusted and can access all files in the subfolder of your flash/flex projects folder.</p>
<p>Thanks to a hint of nada there is <strong>a way to come around of the buggy Security Settings Manager</strong>. You can add a new cfg file in the FlashPlayerTrust directory (win: C:\windows\system32\Macromed\Flash\FlashPlayerTrust | mac: /Library/Application Support/Macromedia/FlashPlayerTrust ) and add your trusted folders in this cfg file. So my config file:</p>
<p>/Library/Application Support/Macromedia/FlashPlayerTrust/flexprojects.cfg</p>
<p>contains one single path to my flex projects:</p>
<p>/Users/mich/Flex Projects</p>
<p>And all my projects have access to local resources that are in this folder or in subfolders. One entry and you dont have to worry about any local access restrictions.</p>
<p><strong>Summary</strong></p>
<p>Both ways you are able to access both local and network resources. The advantage of the network-security sandbox way is that you have to add an entry only once and not every time you access a new domain. Specially if you set it up with your root flex/flash projects folder all your projects have automatically access.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/09/error-2148-or-how-to-access-local-and-network-resources/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>TextField, StyleSheet and TextFormat</title>
		<link>http://www.indieas.org/2009/09/textfield-stylesheet-and-textformat/</link>
		<comments>http://www.indieas.org/2009/09/textfield-stylesheet-and-textformat/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 09:08:35 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[defaultTextFormat]]></category>
		<category><![CDATA[stylesheet]]></category>
		<category><![CDATA[textfield]]></category>
		<category><![CDATA[textformat]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=88</guid>
		<description><![CDATA[I&#8217;m sure that everybody that ever try to apply a stylesheet to a textfield in Flash encountered some problems. Thats why I though I will write a summary about the workaround that I found so far. First thing to know is how flash can apply css on text. If you set for example: You can [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure that everybody that ever try to apply a stylesheet to a textfield in Flash encountered some problems. Thats why I though I will write a summary about the workaround that I found so far.</p>
<p>First thing to know is how flash can apply css on text. If you set for example:</p>
<pre class="brush: as3; title: ; notranslate">
textField.text = &quot;Hello is it &lt;b&gt;me&lt;/b&gt; you &lt;h1&gt;looking&lt;/h1&gt; for.&quot;;
</pre>
<p>You can style the text between tags here: <em>&lt;b&gt;..&lt;/b&gt;</em> and <em>&lt;h1&gt;&#8230;&lt;/h1&gt;</em> if you define css definition for these tags. An example css file would look like:</p>
<pre class="brush: css; title: ; notranslate">
b {  font-weight: bold; }
h1 {  size:16; }
</pre>
<p>and the corresponding as source to set the styleSheet would be:</p>
<pre class="brush: as3; title: ; notranslate">
private function onLoaded( e:Event ):void {
// The TextLoader is a class from the indieas library
var loader:TextLoader = e.target as TextLoader;
var css:StyleSheet = loader.getDataAsCSS();
textField.styleSheet = css;
textField.text = &quot;Hello is it &lt;b&gt;me&lt;/b&gt; you &lt;h1&gt;looking&lt;/h1&gt; for.&quot;;
}
</pre>
<p>Here its important that you set the text property after setting the styleSheet otherwise it will not apply the styles.</p>
<p>So far everything works as expected but what if you also want to style the normal text without any tags. You could wrap the text content in another tag like:</p>
<pre class="brush: xml; title: ; notranslate">&lt;text&gt;Hello is it &lt;b&gt;me&lt;/b&gt; you &lt;h1&gt;looking&lt;/h1&gt; for.&lt;/text&gt;</pre>
<p>But thats not very handy instead we use the TextField own property defaultTextFormat. We can transform a css into a TextFormat and apply that as defaultTextFormat like this:</p>
<pre class="brush: as3; title: ; notranslate">
var styleObject:Object = css.getStyle( &quot;*&quot; );
var defaultStyle:TextFormat = css.transform( styleObject );
textField.defaultTextFormat = defaultStyle;
textField.styleSheet = css;
textField.text = &quot;Hello is it &lt;b&gt;me&lt;/b&gt; you &lt;h1&gt;looking&lt;/h1&gt; for.&quot;;
</pre>
<p>Again here the order of applying defaultTextFormat, styleSheet and text is important. If you have a styleSheet applied and you want to set the defaultTextFormat it will throw an error. So if you want to reapply the defaultTextFormat do it like this:</p>
<pre class="brush: as3; title: ; notranslate">
var style:StyleSheet = textField.styleSheet; // save the styles to reapply them later
textField.styleSheet = null; // set this null to allow seting the defaultTextFormat
textField.defaultTextFormat = // new format;
textField.styleSheet = style; // reapply styles
textField.text = textField.text; // reapply text
</pre>
<p>The last thing to mention is the textField.condenseWhite property. Very often you load your content from an xml file and like to show a node content in a textField. But as the xml itself has linespaces and breaks the shown text is weird formatted. To avoid this use textField.condenseWhite = true. To make a new line just add a &lt;br/&gt; tag to your xml content and make sure your textfield has multiline set to true.</p>
<p><strong>Summary:</strong></p>
<ul>
<li>use defaultTextFormat for default text style.</li>
<li>transform the defaultTextFormat from a StyleSheet style.</li>
<li>properties set order: defaultTextFormat, styleSheet, text.</li>
<li>set condenseWhite = true when setting xml content to the texfield.</li>
</ul>
<p>To play around download a demo FlexBuilder project <a href="http://www.indieas.org/wp-content/uploads/2009/09/textfield_css_demo.zip" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/09/textfield-stylesheet-and-textformat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Another Flash-FlexBuilder workflow: The Draft</title>
		<link>http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-draft/</link>
		<comments>http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-draft/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 16:12:23 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[assets]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[swc]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=80</guid>
		<description><![CDATA[After my introduction article about my workflow I like to dig in a bit deeper and describe you my way of working with Flash and Flex. So far we have the assets ready to use but we need to add functionality to the assets so how do we join these to things together. One approach [...]]]></description>
			<content:encoded><![CDATA[<p>After my <a href="http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-basics/">introduction article</a> about my workflow I like to dig in a bit deeper and describe you my way of working with Flash and Flex. So far we have the assets ready to use but we need to add functionality to the assets so how do we join these to things together. One approach would be to extend from the exported MovieClip. So in my example that would be:</p>
<pre class="brush: as3; title: ; notranslate">
package {
 public class ControllBar extends ControllerBarDraft {

 public function ControllBar() {
 super();

 playButton.alpha = 0.5;
 }
 }
}
</pre>
<p>This way we have all assets on the timeline ready to use. Nothing more to do. But there is one major drawback. What when we want to extend from another class that from our exported MovieClip? You maybe think this happens not that often &#8211; but it does &#8211; so we can use this approach.</p>
<p>Luckily there is another way to come around that problem. We can simply instantiate the ControllerBarDraft (exported from Flash through swc) and copy the assets to our main class. That would look something like this:</p>
<pre class="brush: as3; title: ; notranslate">
package {
 import flash.display.SimpleButton;
 import flash.display.Sprite;

 public class ControllBar extends Sprite {

 public function ControllBar() {
 super();

 var cbd:ControllerBarDraft = new ControllerBarDraft();
 var playButton:SimpleButton = cbd.removeChild( cbd.playButton );
 addChild( playButton );
 }
 }
}
</pre>
<p>This is pretty cumbersome to do that for everything placed on the ControllerBarDraft MovieClip so I was looking for a way to do that automatically. And I ended up with a simple but powerfull <strong>Draft</strong> class. The core is this method:</p>
<pre class="brush: as3; title: ; notranslate">
public static function copyAssets( from:DisplayObjectContainer, target:DisplayObjectContainer ):* {

 while ( from.numChildren &gt; 0) {

 var current:DisplayObject = from.removeChildAt( 0 );
 target.addChild( current );
 }

 return from;
 }
</pre>
<p>This preserves the z-order but more important it copies the whole DisplayObject with its blendMode, filters, colorTransformations etc.  It also copies normal shapes that you draw in Flash on the timeline. Simply it just copies everything into your class that you will work on. The code with the Draft class looks like this:</p>
<pre class="brush: as3; title: ; notranslate">
package {
 import flash.display.Sprite;

 import org.indieas.util.Draft;

 public class ControllBar extends Sprite {

 public function ControllBar() {
 super();

 var draft:ControllerBarDraft = Draft.copyAssetsFromClass( ControllerBarDraft, this );
 }
 }
}
</pre>
<p>So the assets are in place on your ControllerBar class but you probably need a reference to the playButton that you put inside the ControllerBarDraft thats why you get back this <em>draft</em> reference. To get the playButton you have now autocomplete on the draft instance as you see:</p>
<p><img class="alignnone size-full wp-image-81" title="Picture 13" src="http://www.indieas.org/wp-content/uploads/2009/09/Picture-13.png" alt="Picture 13" width="399" height="196" /></p>
<p>So you can now decide if you need a reference as an attribute in your class or if you just have to setup a listener or do something once in the constructor as the following example shows:</p>
<pre class="brush: as3; title: ; notranslate">
package {
 import flash.display.SimpleButton;
 import flash.display.Sprite;
 import flash.events.MouseEvent;

 import org.indieas.util.Draft;

 public class ControllBar extends Sprite {

 private var playButton:SimpleButton;

 public function ControllBar() {
 super();

 var draft:ControllerBarDraft = Draft.copyAssetsFromClass( ControllerBarDraft, this );
 playButton = draft.playButton;

 draft.stopButton.addEventListener( MouseEvent.CLICK, onStop );
 }
 }
}
</pre>
<p>This is now already very handy but as I have the Draft class I added some more functionality. I personally like the fact that I do the design part in Flash and the coding in FlexBuilder. But I am not a big fan of setting up position and width/height for everything I do by code. So I though that can do the Draft class for me and I added a method like this:</p>
<pre class="brush: as3; title: ; notranslate">
package {
 import flash.display.Sprite;

 import org.indieas.util.Draft;
 import org.indieas.widgets.scrollbar.ScrollBar;

 public class ControllBar extends Sprite {

 public function ControllBar() {
 super();

 var draft:ControllerBarDraft = Draft.copyAssetsFromClass( ControllerBarDraft, this );

 var scrollBar:ScrollBar = Draft.replaceAsset( draft.playButton, ScrollBar );
 }
 }
}
</pre>
<p>Now this is replacing my draft element &#8220;playButton&#8221; with a new instance of a ScrollBar class. The width, height, x, y and so on is automatically applied. What this allows you is to put <strong>placeholders</strong> in your design and swap them later with our DisplayObject classes you like. You can think of a design where you need a TextArea and some other visual elements around. You use a simple box as a placeholder where the TextArea should belong and export that and replace the placeholder with the TextArea class with the help of the Draft class. If there are design updates you dont have to change anything in your code you simple just adjust the placeholder in your MovieClip and hit CTRL-ENTER to update the swc.</p>
<p>So far I very happy with this workflow because it allows me to have full controll over my class &#8211; what I need as attribute &#8211; but also hide the elements I dont need. Something that I forgot to mention so far is the fact that you can work easily with <strong>multiple people on one project</strong> when they have their own fla files and export their swc&#8217;s.</p>
<p>If you like to play around with the Draft class you can either download the <a href="http://www.indieas.org/wp-content/uploads/2009/09/workflow_draft.zip">demo flex project</a> or download our <a href="http://www.indieas.org/library/">indieas library</a> where you have also more stuff to explore.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-draft/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Another Flash-FlexBuilder workflow: The basics</title>
		<link>http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-basics/</link>
		<comments>http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-basics/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 18:19:42 +0000</pubDate>
		<dc:creator>mich</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[swc]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.indieas.org/?p=61</guid>
		<description><![CDATA[You probably remember the mtasc compiler from the old AS2 times. One major benefit was the speed because it didnt compile the graphic assets all over again. With a right setup you can archive the same thing with Flash and Flex. The key is the swc export feature of the Flash IDE: If you export [...]]]></description>
			<content:encoded><![CDATA[<p>You probably remember the mtasc compiler from the old AS2 times. One major benefit was the speed because it didnt compile the graphic assets all over again. With a right setup you can archive the same thing with Flash and Flex.<br />
The key is the swc export feature of the Flash IDE:</p>
<p><img class="alignnone size-full wp-image-62" title="Picture 8" src="http://www.indieas.org/wp-content/uploads/2009/09/Picture-8.png" alt="Picture 8" width="503" height="115" /></p>
<p>If you export your MovieClips from Flash as Classes:</p>
<p><img class="alignnone size-full wp-image-63" title="Picture 9" src="http://www.indieas.org/wp-content/uploads/2009/09/Picture-9.png" alt="Picture 9" width="548" height="346" /></p>
<p>and add the swc in the Flex Builder as library:</p>
<p><img class="alignnone size-full wp-image-64" title="Picture 10" src="http://www.indieas.org/wp-content/uploads/2009/09/Picture-10.png" alt="Picture 10" width="675" height="341" /></p>
<p>you can access/create them by simply create a new instance:</p>
<p><img class="alignnone size-full wp-image-72" title="Picture 12" src="http://www.indieas.org/wp-content/uploads/2009/09/Picture-12.png" alt="Picture 12" width="560" height="258" /></p>
<p>You have to recompile (ctrl-enter in flash) the swc when you change something in your graphic assets. But in the FlexBuilder if you compile it just recompiles the source and includes the assets from the swc.<br />
This workflow looks great in the first moment because you have autocomplete and strict typed access to the assets on the ControllerBarDraft. If you like to play around with the setup I made a simply actionscript FlexBuilder project that you can download <a href="http://www.indieas.org/wp-content/uploads/2009/09/workflow_basics.zip">here</a>.</p>
<p>To use this workflow in an more advanced way, wait for the next article: <a href="http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-draft/">Another Flash-FlexBuilder workflow: The Draft</a>. Where I describe problems of this workflow as a nice workaround. Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indieas.org/2009/09/another-flash-flexbuilder-workflow-the-basics/feed/</wfw:commentRss>
		<slash:comments>1</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>

