﻿<?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>Keith Hair &#187; ActionScript 3</title>
	<atom:link href="http://keith-hair.net/blog/tag/actionscript-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://keith-hair.net/blog</link>
	<description>Scripting is fun like any other hobby</description>
	<lastBuildDate>Sat, 28 Jan 2012 05:04:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Concatenation Tool</title>
		<link>http://keith-hair.net/blog/2012/01/08/concatenation-tool/</link>
		<comments>http://keith-hair.net/blog/2012/01/08/concatenation-tool/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 09:41:13 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSFL]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[combo]]></category>
		<category><![CDATA[Concatenation]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[videogames]]></category>
		<category><![CDATA[XUL]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=393</guid>
		<description><![CDATA[String'n together combos isn't always as fun as doing them in a fighting videogame. If you write script that has a lot String content mixed with variables, I'm sure you're doing a lot of heavy concatenation. Building string combos with quotes and apostrophes sprinkled all over a script gets confusing. The way I like to [...]]]></description>
			<content:encoded><![CDATA[<p>String'n together combos isn't always as fun as doing them in a fighting videogame.<a href="http://keith-hair.net/blog/wp-content/uploads/2012/01/Tekken-Street-2-Piki_thumb.jpg" rel="lightbox[393]"><img src="http://keith-hair.net/blog/wp-content/uploads/2012/01/Tekken-Street-2-Piki_thumb-150x150.jpg" alt="" title="Tekken-Street-2-Piki_thumb" width="150" height="150" class="alignleft size-thumbnail wp-image-431" /></a><a href="http://keith-hair.net/works/2011/concatenator/" target="_blank"><img src="http://keith-hair.net/blog/wp-content/uploads/2012/01/concatenatorUI1-150x150.jpg" alt="" title="concatenatorUI" width="150" height="150" class="alignright size-thumbnail wp-image-441" /></a></p>
<p>If you write script that has a lot String content mixed with variables, I'm sure you're doing a lot of heavy concatenation.<br />
Building string combos with quotes and apostrophes sprinkled all over a script gets confusing. The way I like to keep this confusion to a minimum is to write my static markup separately. This allows me to make sure it shows up as intended. Then I concatenate my variables in all the places that need to have dynamic content.</p>
<p>Taking static markup or script and wrapping quotes around every line is a chore so I made this <a href="http://keith-hair.net/works/2011/concatenator/" title="Concatenation Tool" target="_blank">Concatenation Tool</a> to help with that.</p>
<p>Currently I've only made this support languages I'm using mostly. If I have to use a new language I'd just add it in.<br />
<span id="more-393"></span></p>
<p>Below are some basic use case examples of where a concatenation tool can be useful. </p>
<hr></hr>
<p><strong>JavaScript</strong><br />
<em>Concatenating a content to add to a Jquery UI Dialog.<br />
In this example I purposely used he "text()" method to show the XML content instead of "html()".</em></p>
<pre class="brush: jscript; title: ; notranslate">
    &lt;script type=&quot;text/javascript&quot;&gt;
                $(document).ready(function(){
                var ns = &quot;&quot;;
                ns += &quot;&lt;LIBRARY&gt;&quot;;
                ns += &quot;    &lt;BOOK&gt;&quot;;
                ns += &quot;        &lt;TITLE id=\&quot;2356\&quot;&gt;Charlotte's Web&lt;/TITLE&gt;&quot;;
                ns += &quot;        &lt;AUTHOR&gt;E. B. White&lt;/AUTHOR&gt;&quot;;
                ns += &quot;        &lt;FAMOUS_SAYING&gt;\&quot;Always be on the lookout for the presence of wonder.\&quot;&lt;/FAMOUS_SAYING&gt;&quot;;
                ns += &quot;    &lt;/BOOK&gt;&quot;;
                ns += &quot;    &lt;BOOK&gt;&quot;;
                ns += &quot;        &lt;TITLE id=\&quot;95\&quot;&gt;Scuffy the Tugboat&lt;/TITLE&gt;&quot;;
                ns += &quot;        &lt;AUTHOR&gt;Gertrude Crampton&lt;/AUTHOR&gt;&quot;;
                ns += &quot;        &lt;FAMOUS_SAYING&gt;\&quot;Toot, tooot!\&quot; cried the frightened tugboat.&lt;/FAMOUS_SAYING&gt;&quot;;
                ns += &quot;    &lt;/BOOK&gt;&quot;;
                ns += &quot;&lt;/LIBRARY&gt;&quot;;
                $(&quot;#myDialog&quot;).dialog({width:400, height:400});
                $(&quot;#myDialog p&quot;).text(ns);
                });
    &lt;/script&gt;
</pre>
<p><a href="http://keith-hair.net/blog/wp-content/uploads/2012/01/jqueryui_sample.jpg" rel="lightbox[393]"><img src="http://keith-hair.net/blog/wp-content/uploads/2012/01/jqueryui_sample.jpg" alt="" title="jqueryui_sample" width="462" height="427" class="alignnone size-full wp-image-409" /></a></p>
<hr></hr>
<p><strong>Python</strong><br />
<em>Concatenating with qoutes</em></p>
<pre class="brush: python; title: ; notranslate">
ns = &quot;&quot;
ns += &quot;&lt;LIBRARY&gt;&quot;
ns += &quot;    &lt;BOOK&gt;&quot;
ns += &quot;        &lt;TITLE id=\&quot;2356\&quot;&gt;Charlotte's Web&lt;/TITLE&gt;&quot;
ns += &quot;        &lt;AUTHOR&gt;E. B. White&lt;/AUTHOR&gt;&quot;
ns += &quot;        &lt;FAMOUS_SAYING&gt;\&quot;Always be on the lookout for the presence of wonder.\&quot;&lt;/FAMOUS_SAYING&gt;&quot;
ns += &quot;    &lt;/BOOK&gt;&quot;
ns += &quot;    &lt;BOOK&gt;&quot;
ns += &quot;        &lt;TITLE id=\&quot;95\&quot;&gt;Scuffy the Tugboat&lt;/TITLE&gt;&quot;
ns += &quot;        &lt;AUTHOR&gt;Gertrude Crampton&lt;/AUTHOR&gt;&quot;
ns += &quot;        &lt;FAMOUS_SAYING&gt;\&quot;Toot, tooot!\&quot; cried the frightened tugboat.&lt;/FAMOUS_SAYING&gt;&quot;
ns += &quot;    &lt;/BOOK&gt;&quot;
ns += &quot;&lt;/LIBRARY&gt;&quot;
print(ns)
</pre>
<p><em>Python concatenation with triple quotes to preserve the carriage returns</em></p>
<pre class="brush: python; title: ; notranslate">
ns=&quot;&quot;&quot;&lt;LIBRARY&gt;
    &lt;BOOK&gt;
        &lt;TITLE id=&quot;2356&quot;&gt;Charlotte's Web&lt;/TITLE&gt;
        &lt;AUTHOR&gt;E. B. White&lt;/AUTHOR&gt;
        &lt;FAMOUS_SAYING&gt;&quot;Always be on the lookout for the presence of wonder.&quot;&lt;/FAMOUS_SAYING&gt;
    &lt;/BOOK&gt;
    &lt;BOOK&gt;
        &lt;TITLE id=&quot;95&quot;&gt;Scuffy the Tugboat&lt;/TITLE&gt;
        &lt;AUTHOR&gt;Gertrude Crampton&lt;/AUTHOR&gt;
        &lt;FAMOUS_SAYING&gt;&quot;Toot, tooot!&quot; cried the frightened tugboat.&lt;/FAMOUS_SAYING&gt;
    &lt;/BOOK&gt;
&lt;/LIBRARY&gt;&quot;&quot;&quot;
print(ns)
</pre>
<p><em>Concatenation with regular quotes</em><br />
<a href="http://keith-hair.net/blog/wp-content/uploads/2012/01/samplepy2.jpg" rel="lightbox[393]"><img src="http://keith-hair.net/blog/wp-content/uploads/2012/01/samplepy2.jpg" alt="" title="Concatenation of blocks of text with triple quotes" width="682" height="358" class="alignnone size-full wp-image-413" /></a></p>
<p><em>Concatenation of blocks of text with triple quotes</em><br />
<a href="http://keith-hair.net/blog/wp-content/uploads/2012/01/samplepy1.jpg" rel="lightbox[393]"><img src="http://keith-hair.net/blog/wp-content/uploads/2012/01/samplepy1.jpg" alt="" title="Concatenation with regular quotes" width="698" height="357" class="alignnone size-full wp-image-412" /></a></p>
<hr></hr>
<p><strong>JSFL</strong><br />
<em>Concatenating a XUL markup string for building Flash IDE Panel with JSFL.</em></p>
<pre class="brush: jscript; title: ; notranslate">
if(fl.documents.length == 0){
	fl.createDocument(&quot;timeline&quot;);
}
//------------------------------------------------------------
//An existing folder for the panel's source to be written to.
//------------------------------------------------------------
var appFolderName=&quot;jsflUI_sample&quot;;
var date=new Date();
function writePanelSource()
{
	var code = '';
	code += '&lt;overlay&gt;';
	code += '	&lt;dialog id=&quot;app&quot; title=&quot;Sample UI&quot;&gt;';
	code += '		&lt;hbox&gt;';
	code += '			&lt;spacer/&gt;';
	code += '			&lt;button id=&quot;b0&quot; label=&quot;Button&quot;/&gt;';
	code += '		&lt;/hbox&gt;';
	code += '		&lt;separator/&gt;';
	code += '		&lt;vbox&gt;';
	code += '			&lt;label control=&quot;f0&quot; value=&quot;Field 1&quot; align=&quot;left&quot;/&gt;';
	code += '			&lt;textbox id=&quot;f0&quot; size=&quot;50&quot; value=&quot;'+date.toString()+'&quot;/&gt;';
	code += '			&lt;label control=&quot;f1&quot; value=&quot;Field 2:&quot; align=&quot;left&quot;/&gt;';
	code += '			&lt;textbox id=&quot;f1&quot; size=&quot;50&quot; value=&quot;&quot;/&gt;';
	code += '		&lt;/vbox&gt;';
	code += '		&lt;checkbox id=&quot;cb0&quot; label=&quot;Checkbox 1&quot; checked=&quot;false&quot; /&gt;';
	code += '		&lt;checkbox id=&quot;cb1&quot; label=&quot;Checkbox 2&quot; checked=&quot;false&quot; /&gt;';
	code += '	&lt;/dialog&gt;';
	code += '&lt;/overlay&gt;';
	FLfile.write(fl.configURI + &quot;Commands/&quot;+appFolderName+&quot;/panelsource.xml&quot;, code);
	return code;
}

//----------------------------------------------------------------
//Writes the markup to &quot;appFolderName&quot; of Flash's &quot;Commands folder
//----------------------------------------------------------------
writePanelSource();

//-------------------------------
//Open the Panel in Flash's IDE
//-------------------------------
fl.getDocumentDOM().xmlPanel(fl.configURI + &quot;Commands/&quot;+appFolderName+&quot;/panelsource.xml&quot;);
</pre>
<p><em>Panel UI dialog from JSFL</em><br />
<a href="http://keith-hair.net/blog/wp-content/uploads/2012/01/jsflUI_sample.jpg" rel="lightbox[393]"><img src="http://keith-hair.net/blog/wp-content/uploads/2012/01/jsflUI_sample.jpg" alt="" title="jsflUI_sample" class="alignnone"/></a></p>
<hr></hr>
<p><strong>SharePoint</strong><br />
<em>Concatenating CAML querys.</em></p>
<pre class="brush: jscript; title: ; notranslate">
function getListData()
{
	var clientContext = new SP.ClientContext.get_current();
	var web = clientContext.get_web();
	var userInfoList = web.get_lists().getByTitle('user_list')
	var camlQuery = new SP.CamlQuery();
	var caml = '';
	caml += '&lt;View&gt;';
	caml += '	&lt;Query&gt;';
	caml += '		&lt;OrderBy&gt;';
	caml += '			&lt;FieldRef Name=&quot;Title&quot; Ascending=&quot;False&quot; /&gt;';
	caml += '		&lt;/OrderBy&gt;';
	caml += '	&lt;/Query&gt;';
	caml += '&lt;/View&gt;';
	camlQuery.set_viewXml(caml);
	collListItem = userInfoList.getItems(camlQuery);
	clientContext.load(collListItem);
	var onQuerySucceeded=function(sender, args)
	{
		var oitem;
		var s='';
		var n=0;
		var len=collListItem.get_count();
		var results=[];
		while(n &lt; len)
		{
			oitem = collListItem.itemAt(n);
			s+=&quot;Title:&quot;+oitem.get_item(&quot;Title&quot;)+&quot;&lt;br&gt;&lt;/br&gt;&quot;;
			n++;
		}
		$(&quot;#output&quot;).append(s);
	}
	var onQueryFailed=function(sender, args)
	{
		alert(&quot;Failed getting data.&quot;)
	}
	clientContext.executeQueryAsync
        (
        Function.createDelegate(this, onQuerySucceeded),
        Function.createDelegate(this, onQueryFailed)
        );
}
</pre>
<p><em>Output of Title column from a SharePoint 2010 list.</em><br />
<a href="http://keith-hair.net/blog/wp-content/uploads/2012/01/sharepoint_sample.jpg" rel="lightbox[393]"><img src="http://keith-hair.net/blog/wp-content/uploads/2012/01/sharepoint_sample.jpg" alt="" title="SharePoint output" width="427" height="376" class="alignnone size-full wp-image-423" /></a></p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2012/01/08/concatenation-tool/&ztz=Concatenation Tool'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2012/01/08/concatenation-tool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Draggable TitleWindows in Flash Builder</title>
		<link>http://keith-hair.net/blog/2010/11/18/draggable-titlewindows-in-flash-builder/</link>
		<comments>http://keith-hair.net/blog/2010/11/18/draggable-titlewindows-in-flash-builder/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 04:28:57 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[TitleWindow]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=240</guid>
		<description><![CDATA[I like using MXML because it is quicker than writing ActionScript for a lot tasks. When you create a TitleWindow in MXML, it is not draggable. To make a TitleWindow draggable you have to create the window in ActionScript using the PopUpManager methods "createPopUp" or "addPopUp" I wanted this process simpler so that next time [...]]]></description>
			<content:encoded><![CDATA[<p>I like using MXML because it is quicker than writing ActionScript for a lot tasks.<br />
When you create a TitleWindow in MXML, it is not draggable.<br />
To make a TitleWindow draggable you have to create the window in ActionScript using the PopUpManager methods "createPopUp" or "addPopUp"<br />
I wanted this process simpler so that next time I wanted a draggable window, I could just use a simple MXML tag.</p>
<p>Here I extended the TitleWindow to make it be automatically added with the PopUpManager.<br />
Also all the child components get carried over after PopUpManager is used.<br />
I did this so I could lazily use MXML and all references to this component instance stay intact, because the PopUpManager is using the same instance of the MXML component.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_WindowsProject_1788153222"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/blog/examples/draggabletitlewindow/WindowsProject.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/draggabletitlewindow/WindowsProject.swf"
			name="fm_WindowsProject_1788153222"
			width="550"
			height="400">
	<!--<![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>The "Move Left" and "Move Right" buttons show that the references are ok.</p>
<p><span id="more-240"></span></p>
<p>MXML in "net/keithhair/FloatWindow.mxml"</p>
<pre class="actionscript">&nbsp;
&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?&gt;
&lt;s:TitleWindow creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span>
			   xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span>
			   xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>
			   xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span>
			   autoLayout=<span style="color: #ff0000;">&quot;true&quot;</span>
			   <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;400&quot;</span>
			   <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;300&quot;</span>&gt;
	&lt;fx:Script&gt;
		&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">CloseEvent</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">managers</span>.<span style="color: #006600;">PopUpManager</span>;
			<span style="color: #0066CC;">import</span> spark.<span style="color: #006600;">components</span>.<span style="color: #006600;">Group</span>;
			<span style="color: #0066CC;">import</span> spark.<span style="color: #006600;">components</span>.<span style="color: #006600;">VGroup</span>;
&nbsp;
			protected <span style="color: #000000; font-weight: bold;">var</span> _vgroup:Group;
&nbsp;
			protected <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> p:<span style="color: #0066CC;">String</span>;
				<span style="color: #000000; font-weight: bold;">var</span> n:<span style="color: #0066CC;">int</span>;
				<span style="color: #000000; font-weight: bold;">var</span> a:<span style="color: #0066CC;">Array</span>=<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
				<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">_parent</span>:DisplayObject=parent;
				<span style="color: #808080; font-style: italic;">//---------------------------------------------</span>
				<span style="color: #808080; font-style: italic;">//Remove all the child elements store</span>
				<span style="color: #808080; font-style: italic;">//the references in an Array</span>
				<span style="color: #808080; font-style: italic;">//---------------------------------------------</span>
				n=numElements - <span style="color: #cc66cc;">1</span>;
				<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>n &gt; <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					a.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>removeElementAt<span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
					n--;
				<span style="color: #66cc66;">&#125;</span>
				Group<span style="color: #66cc66;">&#40;</span>parent<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">removeElement</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #808080; font-style: italic;">//---------------------------------------------</span>
				<span style="color: #808080; font-style: italic;">//Add a popup of a this TitleWindow instance,</span>
				<span style="color: #808080; font-style: italic;">//Create a layout container and add all</span>
				<span style="color: #808080; font-style: italic;">//the children back into it.</span>
				<span style="color: #808080; font-style: italic;">//---------------------------------------------</span>
				PopUpManager.<span style="color: #006600;">addPopUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, <span style="color: #0066CC;">_parent</span><span style="color: #66cc66;">&#41;</span>;
				n=a.<span style="color: #0066CC;">length</span> - <span style="color: #cc66cc;">1</span>;
				_vgroup=<span style="color: #000000; font-weight: bold;">new</span> VGroup<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				_vgroup.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;top&quot;</span>,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
				_vgroup.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;bottom&quot;</span>,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
				_vgroup.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;left&quot;</span>,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
				_vgroup.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;right&quot;</span>,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
				addElement<span style="color: #66cc66;">&#40;</span>_vgroup<span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>n &gt; <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					_vgroup.<span style="color: #006600;">addElement</span><span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
					n--;
				<span style="color: #66cc66;">&#125;</span>
				addEventListener<span style="color: #66cc66;">&#40;</span>CloseEvent.<span style="color: #0066CC;">CLOSE</span>, closer<span style="color: #66cc66;">&#41;</span>;
				PopUpManager.<span style="color: #006600;">centerPopUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
				p=<span style="color: #000000; font-weight: bold;">null</span>;
				n=<span style="color: #cc66cc;">0</span>;
				a=<span style="color: #000000; font-weight: bold;">null</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			protected <span style="color: #000000; font-weight: bold;">function</span> closer<span style="color: #66cc66;">&#40;</span>evt:CloseEvent<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>CloseEvent.<span style="color: #0066CC;">CLOSE</span>, <span style="color: #0066CC;">arguments</span>.<span style="color: #0066CC;">callee</span><span style="color: #66cc66;">&#41;</span>;
				PopUpManager.<span style="color: #006600;">removePopUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;
	&lt;/fx:Script&gt;
&lt;/s:TitleWindow&gt;
&nbsp;</pre>
<p>Now I can simply use MXML to make my draggable windows.<br />
The window is draggable and all the<br />
MXML children are there too.</p>
<pre class="actionscript">&nbsp;
	&lt;keithhair:FloatWindow id=<span style="color: #ff0000;">&quot;mywindow&quot;</span>
			       title=<span style="color: #ff0000;">&quot;My Window&quot;</span>
			       <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;250&quot;</span>
			       <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;300&quot;</span>&gt;
		&lt;mx:TabNavigator <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span>
				 <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span>&gt;
			&lt;mx:VBox label=<span style="color: #ff0000;">&quot;Buttons&quot;</span>&gt;
				&lt;s:<span style="color: #0066CC;">Button</span>/&gt;
				&lt;s:<span style="color: #0066CC;">Button</span>/&gt;
				&lt;s:<span style="color: #0066CC;">Button</span>/&gt;
			&lt;/mx:VBox&gt;
			&lt;mx:VBox label=<span style="color: #ff0000;">&quot;Checkboxes&quot;</span>&gt;
				&lt;s:CheckBox/&gt;
				&lt;s:CheckBox/&gt;
				&lt;s:CheckBox/&gt;
			&lt;/mx:VBox&gt;
			&lt;mx:VBox label=<span style="color: #ff0000;">&quot;TextAreas&quot;</span>&gt;
				&lt;s:TextArea/&gt;
				&lt;s:TextArea/&gt;
			&lt;/mx:VBox&gt;
		&lt;/mx:TabNavigator&gt;
	&lt;/keithhair:FloatWindow&gt;
&nbsp;</pre>
<p>If you know of a more efficient way that does this or can make this better just add your comments to my blog. </p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2010/11/18/draggable-titlewindows-in-flash-builder/&ztz=Draggable TitleWindows in Flash Builder'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2010/11/18/draggable-titlewindows-in-flash-builder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Find and Replace for XML in AS3</title>
		<link>http://keith-hair.net/blog/2008/05/30/find-and-replace-for-xml-in-as3/</link>
		<comments>http://keith-hair.net/blog/2008/05/30/find-and-replace-for-xml-in-as3/#comments</comments>
		<pubDate>Fri, 30 May 2008 04:26:18 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://keith-hair.com/blog/?p=3</guid>
		<description><![CDATA[These are some functions I wrote for finding and replacing parts of XML using AS3. Not sure if E4X or "XML.replace()" method can be used to make each function's task better. &#160; /*----------------------------------- Recursively replace nodeNames. -------------------------------------*/ private function findAndReplaceTagNames &#40;xml:XML,find:String,replace:String&#41;:XML &#123; if&#40;xml.localName&#40;&#41; == find&#41;&#123; xml.setLocalName&#40;replace&#41;; &#125; var n:int=0; var c:XML; while&#40;n &#60;xml.children&#40;&#41;.length&#40;&#41;&#41;&#123; c=xml.children&#40;&#41;&#91;n&#93;; findAndReplaceTagNames&#40;c,find,replace&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>These are some functions I wrote for finding and replacing parts of XML using AS3.<br />
Not sure if E4X or "XML.replace()" method can be used to make each function's task better.</p>
<pre class="actionscript">&nbsp;
<span style="color: #808080; font-style: italic;">/*-----------------------------------
	Recursively replace nodeNames.
-------------------------------------*/</span>
      <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> findAndReplaceTagNames
      <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span>,find:<span style="color: #0066CC;">String</span>,replace:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">XML</span>
      <span style="color: #66cc66;">&#123;</span>
          <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span>.<span style="color: #006600;">localName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == find<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">setLocalName</span><span style="color: #66cc66;">&#40;</span>replace<span style="color: #66cc66;">&#41;</span>;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #000000; font-weight: bold;">var</span> n:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>;
          <span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #0066CC;">XML</span>;
          <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>n &lt;xml.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              c=<span style="color: #0066CC;">xml</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span>;
              findAndReplaceTagNames<span style="color: #66cc66;">&#40;</span>c,find,replace<span style="color: #66cc66;">&#41;</span>;
              n++;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">xml</span>;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*-----------------------------------------
	Recursively replace attributes.
-------------------------------------------*/</span>
      <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> findAndReplaceAttributeNames
      <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span>,find:<span style="color: #0066CC;">String</span>,replace:<span style="color: #0066CC;">String</span>,in_tags_named:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">XML</span>
      <span style="color: #66cc66;">&#123;</span>
          <span style="color: #000000; font-weight: bold;">var</span> ok:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>;
          <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>in_tags_named != <span style="color: #ff0000;">&quot;&quot;</span> &amp;&amp; <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">localName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> != in_tags_named<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              ok=<span style="color: #000000; font-weight: bold;">false</span>;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span>.@<span style="color: #66cc66;">&#91;</span>find<span style="color: #66cc66;">&#93;</span> != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp; ok<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              <span style="color: #0066CC;">xml</span>.@<span style="color: #66cc66;">&#91;</span>replace<span style="color: #66cc66;">&#93;</span>=<span style="color: #0066CC;">xml</span>.@<span style="color: #66cc66;">&#91;</span>find<span style="color: #66cc66;">&#93;</span>;
              <span style="color: #0066CC;">delete</span> <span style="color: #0066CC;">xml</span>.@<span style="color: #66cc66;">&#91;</span>find<span style="color: #66cc66;">&#93;</span>;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #000000; font-weight: bold;">var</span> n:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>;
          <span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #0066CC;">XML</span>;
          <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>n &lt;xml.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              c=<span style="color: #0066CC;">xml</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span>;
              findAndReplaceAttributeNames<span style="color: #66cc66;">&#40;</span>c,find,replace<span style="color: #66cc66;">&#41;</span>;
              n++;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">xml</span>;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*---------------------------------------------
	Recursively find and remove attributes.
-----------------------------------------------*/</span>
      <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> findAndRemoveAttributeNames
      <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span>,find:<span style="color: #0066CC;">String</span>,in_tags_named:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">XML</span>
      <span style="color: #66cc66;">&#123;</span>
          <span style="color: #000000; font-weight: bold;">var</span> ok:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>;
          <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>in_tags_named != <span style="color: #ff0000;">&quot;&quot;</span> &amp;&amp; <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">localName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> != in_tags_named<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              ok=<span style="color: #000000; font-weight: bold;">false</span>;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span>.@<span style="color: #66cc66;">&#91;</span>find<span style="color: #66cc66;">&#93;</span> != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp; ok<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              <span style="color: #0066CC;">delete</span> <span style="color: #0066CC;">xml</span>.@<span style="color: #66cc66;">&#91;</span>find<span style="color: #66cc66;">&#93;</span>;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #000000; font-weight: bold;">var</span> n:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>;
          <span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #0066CC;">XML</span>;
          <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>n &lt;xml.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
              c=<span style="color: #0066CC;">xml</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span>;
              findAndRemoveAttributeNames<span style="color: #66cc66;">&#40;</span>c,find<span style="color: #66cc66;">&#41;</span>;
              n++;
          <span style="color: #66cc66;">&#125;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">xml</span>;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2008/05/30/find-and-replace-for-xml-in-as3/&ztz=Find and Replace for XML in AS3'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2008/05/30/find-and-replace-for-xml-in-as3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

