<?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>FLEX{er} &#187; XML</title>
	<atom:link href="http://www.flexer.info/category/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flexer.info</link>
	<description>flex developers web corner</description>
	<lastBuildDate>Tue, 04 Oct 2011 16:23:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
  <link>http://www.flexer.info</link>
  <url>http://www.flexer.info/favicon.ico</url>
  <title>FLEX{er}</title>
</image>
		<item>
		<title>HTTPService Requesting XML from FeedBurner Gets Parsed with XSL in IE Browser</title>
		<link>http://www.flexer.info/2008/09/10/httpservice-requesting-xml-from-feedburner-gets-parsed-with-xsl-in-ie-browser/</link>
		<comments>http://www.flexer.info/2008/09/10/httpservice-requesting-xml-from-feedburner-gets-parsed-with-xsl-in-ie-browser/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 15:32:10 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[feedburner]]></category>
		<category><![CDATA[xsl]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=252</guid>
		<description><![CDATA[These day I&#8217;ve been fighting with this issue: trying to get the Flexer XML feed from FeedBurner into a Flex application. As many of you may know FeedBurner serves the XML with an XSL and browsers that know XSL will parse it and display it in a nicer way that a simple xml.
The problem is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F09%2F10%2Fhttpservice-requesting-xml-from-feedburner-gets-parsed-with-xsl-in-ie-browser%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F09%2F10%2Fhttpservice-requesting-xml-from-feedburner-gets-parsed-with-xsl-in-ie-browser%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/09/10/httpservice-requesting-xml-from-feedburner-gets-parsed-with-xsl-in-ie-browser/&title=HTTPService+Requesting+XML+from+FeedBurner+Gets+Parsed+with+XSL+in+IE+Browser&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>These day I&#8217;ve been fighting with this issue: trying to get the <a href="http://feeds.feedburner.com/flexer/" target="_blank">Flexer XML feed</a> from FeedBurner into a Flex application. As many of you may know FeedBurner serves the XML with an XSL and browsers that know XSL will parse it and display it in a nicer way that a simple xml.</p>
<p>The problem is that I use IE 7 for development and debugging which is not the best thing to do. So I did a small application to read a feed from an specified URL.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_test_feedburner_1761064289"
			class="flashmovie"
			width="370"
			height="310">
	<param name="movie" value="/wp-content/uploads/2008/09/test_feedburner.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/09/test_feedburner.swf"
			name="fm_test_feedburner_1761064289"
			width="370"
			height="310">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
At run-time in IE I always got this error (is displayed after clicking on <strong>Get HTTPService</strong> button with <strong>format=&#8221;xml&#8221;</strong> unchecked &#8211; <strong style="color:red">ONLY IN IE</strong>) : </p>
<blockquote style="color:red"><p>Error #1085: The element type &#8220;link&#8221; must be terminated by the matching end-tag &#8220;&lt;/link&gt;&#8221;.</p></blockquote>
<p>When I did look in the <strong>message.body</strong> property of the fault event I was shocked to see that what I get is a HTML page &#8211; NOT an XML one. HTML pages do have tags that do not close like &#8220;link&#8221; tag used to add CSS to the page.</p>
<p>I tried every property of HTTP service, some headers and content types, I also made a URLRequest approach but the same thing.</p>
<p>In the other browser the things were different. Everything was OK. I was requesting for an XML I got an XML. That is great! But I still need to make it work in IE.</p>
<p>It seems that IE is different&#8230; It parses everything before sending it to the flash player. I&#8217;m not a hundred percent sure if is correct what I am saying but that is how I explained it. Then a <a href="http://www.flexer.info/author/qbic/" target="_blank">&#8220;brilliant&#8221; colleague of mine</a> found the needed thing &#8211; in the request add <strong>format = &#8220;xml&#8221;</strong> as request. It seems that when <strong>format = &#8220;xml&#8221;</strong> is set FeedBurner sends another header back to IE browser which will tell the browser not to parse the XML with XSL. So, I did it like below (starting with line 11 in the whole code):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">testGetUrl.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>useFormat.<span style="color: #006600;">selected</span> ? <span style="color: #66cc66;">&#123;</span>format:<span style="color: #ff0000;">'xml'</span><span style="color: #66cc66;">&#125;</span> : <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Notice <strong>{format:&#8221;xml&#8221;</strong>} object which holds our request parameter.</p>
<p>Here is the whole code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<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>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;370&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;310&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:HTTPService id=<span style="color: #ff0000;">&quot;testGetUrl&quot;</span> 
        fault=<span style="color: #ff0000;">&quot;handleFault(event)&quot;</span>
        result=<span style="color: #ff0000;">&quot;handleResult(event)&quot;</span>
        resultFormat=<span style="color: #ff0000;">&quot;e4x&quot;</span>
        <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">&quot;{geturl.text}&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:HTTPService<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span> label=<span style="color: #ff0000;">&quot;Get HTTPService&quot;</span> 
        click=<span style="color: #ff0000;">&quot;testGetUrl.send(
            (useFormat.selected ? {format:'xml'} : {})
        )&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">&quot;137&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span> label=<span style="color: #ff0000;">&quot;Get URLRequest&quot;</span> 
        click=<span style="color: #ff0000;">&quot;handleGetUrlRequest(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:CheckBox id=<span style="color: #ff0000;">&quot;useFormat&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;70&quot;</span> 
        label=<span style="color: #ff0000;">&quot;Use format=&amp;quot;xml&amp;quot;&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;geturl&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> 
        <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;350&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;http://feeds.feedburner.com/flexer/&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextArea id=<span style="color: #ff0000;">&quot;geturlresp&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;96&quot;</span> 
        <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;350&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;204&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FaultEvent</span>;
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleFault<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FaultEvent<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> temp:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">fault</span>.<span style="color: #006600;">faultString</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + 
                    <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> + <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">message</span>.<span style="color: #006600;">body</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                geturlresp.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;HTTPSERVICE FAULT!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> + temp;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleResult<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ResultEvent<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> temp:<span style="color: #66cc66;">*</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">result</span>;
                geturlresp.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;HTTPSERVICE RESULT!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> + 
                    <span style="color: #0066CC;">e</span>.<span style="color: #006600;">result</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleGetUrlRequest<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">var</span> urlReq:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">geturl</span>.<span style="color: #0066CC;">text</span> + 
                    <span style="color: #66cc66;">&#40;</span>useFormat.<span style="color: #006600;">selected</span> ? <span style="color: #ff0000;">&quot;/?format=xml&quot;</span> : <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
&nbsp;
                urlReq.<span style="color: #006600;">method</span> = URLRequestMethod.<span style="color: #0066CC;">GET</span>;
                <span style="color: #000000; font-weight: bold;">var</span> urlLoader:URLLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span>urlReq<span style="color: #66cc66;">&#41;</span>;
                urlLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>
                    Event.<span style="color: #006600;">COMPLETE</span>, handleUrlRequestComplete<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleUrlRequestComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">var</span> tmp:<span style="color: #66cc66;">*</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span>.<span style="color: #0066CC;">data</span>;
                geturlresp.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;URLREQUEST COMPLETE!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> + 
                    tmp.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</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><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>I made also a <strong>URLRequest </strong>option so you can see that is something that is not happening only when using <strong>HTTPService</strong>.</p>
<p>Again&#8230; I want to specify that the error appears <strong>only on IE</strong>.</p>
<p>We may write new articles on this as we will found more about it. <img src='http://www.flexer.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  So keep reading us.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/09/10/httpservice-requesting-xml-from-feedburner-gets-parsed-with-xsl-in-ie-browser/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How To Build a Download Application in Flex</title>
		<link>http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/</link>
		<comments>http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/#comments</comments>
		<pubDate>Mon, 12 May 2008 12:41:40 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[drag]]></category>
		<category><![CDATA[drop]]></category>
		<category><![CDATA[FileReference]]></category>
		<category><![CDATA[HTTPService]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=144</guid>
		<description><![CDATA[In this article I&#8217;ll show the same application I presented at FlexCamp Bucharest Romania 2008 &#8211; the video from the conference is available here and although it is in Romanian it might be useful. In the presentation I&#8217;m showing the power of Flex: doing complex applications with a few lines of codding. 
With this article [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F05%2F12%2Fhow-to-build-a-download-application-in-flex%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F05%2F12%2Fhow-to-build-a-download-application-in-flex%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/&title=How+To+Build+a+Download+Application+in+Flex&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>In this article I&#8217;ll show the same application I presented at <a href="http://myadobe.ro/2008/04/11/flex-camp-aprilie-2008-agenda-a-fost-stabilita/" target="_blank">FlexCamp Bucharest Romania 2008</a> &#8211; the video from the conference is available <a href="http://my.adobe.acrobat.com/p90199006/" target="_blank">here</a> and although it is in Romanian it might be useful. In the presentation I&#8217;m showing the power of Flex: doing complex applications with a few lines of codding. </p>
<p>With this article we are just starting because everything is explained in the powerpoint presentation  and by the comments inside the source code found at the end of this article.</p>
<p>The application is simple &#8211; only one mxml file &#8211; and we will study:</p>
<ul class="ul">
<li>Multiple Drag and drop (<strong>events</strong>)</li>
<li><strong>HTTPService</strong></li>
<li><strong>FileReference</strong></li>
<li><strong>URLRequest</strong></li>
</ul>
<p>On the server-side:</p>
<ul class="ul">
<li><strong>dir.php</strong> &#8211; browsing (http service) – no parameters needed – returns a simple XML</li>
<li><strong>download.php</strong> &#8211; download (url request) – array with the paths that will be included in archive as parameters – returns an archive (tgz)</li>
<li><strong>archive.php</strong> &#8211; class to create arhives</li>
</ul>
<p>On the client-side:</p>
<ul class="ul">
<li>Tree &rArr; HTTPService &rArr; dir.php &rArr; HTTPService &rArr; Tree</li>
<li>Refresh &rArr; HTTPService &rArr; dir.php &rArr; HTTPService &rArr; Tree</li>
<li>Download &rArr; List &rArr; URLRequest &rArr; FileReference &rArr; file download</li>
</ul>
<p>We are using multiple selection and dragging so you can drag more that one item from the list. Also the delete key erases the selected items from the list on the right. You can start over by pressing refresh button.</p>
<p>This is the start of it and you can get into it more and more reading the powerpoints and trying the source codes. All this can be downloaded from the end of this article. </p>
<p>Working example is bellow:<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_draganddrop_1475555359"
			class="flashmovie"
			width="439"
			height="271">
	<param name="movie" value="/wp-content/uploads/2008/05/draganddrop.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/05/draganddrop.swf"
			name="fm_draganddrop_1475555359"
			width="439"
			height="271">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
What can be added in the future:</p>
<ol>
<li>download progress with cancellation possibility</li>
<li>upload functionality</li>
<li>user account functionality</li>
</ol>
<p>The last two points are more difficult because it involves some work on the server-side but is doable.</p>
<p>I&#8217;ve posted also the whole flex source code because it is easier to follow the article and study the code in the same page.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<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>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> 
    <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;439&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;271&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:HTTPService id=<span style="color: #ff0000;">&quot;dir&quot;</span> <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">&quot;{SERVER_URL}dir.php&quot;</span> resultFormat=<span style="color: #ff0000;">&quot;e4x&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Tree id=<span style="color: #ff0000;">&quot;leftTree&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;250&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;204&quot;</span> 
        dataProvider=<span style="color: #ff0000;">&quot;{dir.lastResult}&quot;</span> labelField=<span style="color: #ff0000;">&quot;@name&quot;</span> showRoot=<span style="color: #ff0000;">&quot;false&quot;</span> 
        dragEnabled=<span style="color: #ff0000;">&quot;true&quot;</span> dropEnabled=<span style="color: #ff0000;">&quot;false&quot;</span> allowMultipleSelection=<span style="color: #ff0000;">&quot;true&quot;</span> 
        click=<span style="color: #ff0000;">&quot;showThumb(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> id=<span style="color: #ff0000;">&quot;downloadList&quot;</span> x=<span style="color: #ff0000;">&quot;222&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;135&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;207&quot;</span> 
        allowMultipleSelection=<span style="color: #ff0000;">&quot;true&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{fileListProvider}&quot;</span> 
        dragEnter=<span style="color: #ff0000;">&quot;handleDragEnter(event)&quot;</span> dragOver=<span style="color: #ff0000;">&quot;handleDragOver(event)&quot;</span> 
        dragDrop=<span style="color: #ff0000;">&quot;handleDragDrop(event)&quot;</span> dragExit=<span style="color: #ff0000;">&quot;handleDragExit(event)&quot;</span> 
        click=<span style="color: #ff0000;">&quot;showThumb(event)&quot;</span> keyUp=<span style="color: #ff0000;">&quot;handleKeyUp(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">&quot;downloadButton&quot;</span> x=<span style="color: #ff0000;">&quot;347&quot;</span> y=<span style="color: #ff0000;">&quot;153&quot;</span> label=<span style="color: #ff0000;">&quot;Download&quot;</span> 
        <span style="color: #0066CC;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> click=<span style="color: #ff0000;">&quot;initializeDownload(event)&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">&quot;refreshButton&quot;</span> x=<span style="color: #ff0000;">&quot;347&quot;</span> y=<span style="color: #ff0000;">&quot;239&quot;</span> label=<span style="color: #ff0000;">&quot;Refresh&quot;</span> 
        click=<span style="color: #ff0000;">&quot;refresh(event)&quot;</span>  <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Canvas id=<span style="color: #ff0000;">&quot;imageHolder&quot;</span> x=<span style="color: #ff0000;">&quot;222&quot;</span> y=<span style="color: #ff0000;">&quot;153&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;117&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;108&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:Image id=<span style="color: #ff0000;">&quot;imageThumb&quot;</span> x=<span style="color: #ff0000;">&quot;0&quot;</span> y=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;117&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;108&quot;</span> 
            source=<span style="color: #ff0000;">&quot;{currentPhotoPath}&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Canvas<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">channels</span>.<span style="color: #006600;">StreamingAMFChannel</span>;
            <span style="color: #808080; font-style: italic;">/* File downloading application
               Drag and drop between two different controlers: tree and list */</span>
&nbsp;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">listClasses</span>.<span style="color: #006600;">ListBase</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">managers</span>.<span style="color: #006600;">DragManager</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">DragSource</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">List</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">DragEvent</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// internet - on flexer</span>
            <span style="color: #0066CC;">public</span> const SERVER_URL:<span style="color: #0066CC;">String</span> = 
                <span style="color: #ff0000;">&quot;http://www.flexer.info/wp-content/uploads/2008/05/&quot;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// bindable variable used for the list</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> fileListProvider:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// bindable variable used for thumbnail</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> currentPhotoPath:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> fRef:FileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* initialization function */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// file reference events - used for debug purposes</span>
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">CANCEL</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">OPEN</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">SELECT</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>HTTPStatusEvent.<span style="color: #006600;">HTTP_STATUS</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ProgressEvent.<span style="color: #006600;">PROGRESS</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SecurityErrorEvent.<span style="color: #006600;">SECURITY_ERROR</span>, doEvent<span style="color: #66cc66;">&#41;</span>;				
&nbsp;
                <span style="color: #808080; font-style: italic;">// getting folder content</span>
                dir.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragEnter<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function validates the drop */</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">dragInitiator</span> is Tree<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">var</span> ds:DragSource = event.<span style="color: #006600;">dragSource</span>;
                    <span style="color: #808080; font-style: italic;">// check if the format is what we need - treeItems</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>ds.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> 
                        <span style="color: #b1b100;">return</span>;
                    <span style="color: #000000; font-weight: bold;">var</span> items:<span style="color: #0066CC;">Array</span> = ds.<span style="color: #006600;">dataForFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Array</span>;
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> items.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">XML</span> = <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>items<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #808080; font-style: italic;">// we want only files to be dragable</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>item.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">type</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">&quot;file&quot;</span><span style="color: #66cc66;">&#41;</span> 
                            <span style="color: #b1b100;">return</span>; 
                    <span style="color: #66cc66;">&#125;</span>   
&nbsp;
                    <span style="color: #808080; font-style: italic;">// check for the item to be unique</span>
                    <span style="color: #000000; font-weight: bold;">var</span> paths:ArrayCollection = 
                        downloadList.<span style="color: #006600;">dataProvider</span> as ArrayCollection;
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>; j <span style="color: #66cc66;">&lt;</span> paths.<span style="color: #0066CC;">length</span>; j++<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>item.<span style="color: #66cc66;">@</span>path == paths<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">path</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span>;
                    <span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// accept the drop</span>
                DragManager.<span style="color: #006600;">acceptDragDrop</span><span style="color: #66cc66;">&#40;</span>UIComponent<span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragOver<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function shows feedback to the user */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// show feedback icon</span>
                DragManager.<span style="color: #006600;">showFeedback</span><span style="color: #66cc66;">&#40;</span>DragManager.<span style="color: #0066CC;">COPY</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragDrop<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function adds new items to the list */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// getting source</span>
                <span style="color: #000000; font-weight: bold;">var</span> ds:DragSource = event.<span style="color: #006600;">dragSource</span>;
                <span style="color: #808080; font-style: italic;">// getting target</span>
                <span style="color: #000000; font-weight: bold;">var</span> dropTarget:<span style="color: #0066CC;">List</span> = <span style="color: #0066CC;">List</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// tempoaray array used to add items to list</span>
                <span style="color: #000000; font-weight: bold;">var</span> arr:<span style="color: #0066CC;">Array</span>;
&nbsp;
                <span style="color: #808080; font-style: italic;">// getting the nodes dragged </span>
                <span style="color: #808080; font-style: italic;">// multiple selection is allowed so we have arrays</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>ds.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;items&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    arr = ds.<span style="color: #006600;">dataForFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;items&quot;</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Array</span>;
                <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>ds.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    arr = ds.<span style="color: #006600;">dataForFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Array</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// adding the dragged nodes to list</span>
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> arr.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #808080; font-style: italic;">// getting node</span>
                    <span style="color: #000000; font-weight: bold;">var</span> node:<span style="color: #0066CC;">XML</span> = <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>arr<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #808080; font-style: italic;">// creating new list item</span>
                    <span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #808080; font-style: italic;">// setting item's properties</span>
                    item.<span style="color: #006600;">label</span> = node.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span>;
                    <span style="color: #808080; font-style: italic;">// we set path also which is needed for download</span>
                    item.<span style="color: #006600;">path</span> = node.<span style="color: #66cc66;">@</span>path;
                    <span style="color: #808080; font-style: italic;">// add to data provider</span>
                    fileListProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>item<span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #808080; font-style: italic;">// finish drag</span>
                handleDragExit<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>			
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragExit<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function finishes the drag and drop */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// we hide the feedback</span>
                <span style="color: #000000; font-weight: bold;">var</span> dropTarget:ListBase=ListBase<span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>;
                dropTarget.<span style="color: #006600;">hideDropFeedback</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// we check the data provider to enable the download button</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dropTarget.<span style="color: #006600;">dataProvider</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                    downloadButton.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">true</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> showThumb<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function shows the thumbnail 
                   used for both tree and list click events */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// if click is on the tree</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span>.<span style="color: #0066CC;">name</span> == <span style="color: #ff0000;">&quot;leftTree&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #808080; font-style: italic;">// folders cannot show thumbnail</span>
                    <span style="color: #808080; font-style: italic;">// other file types than images are automatically not shown </span>
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>leftTree.<span style="color: #006600;">selectedItem</span>.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">type</span> == <span style="color: #ff0000;">&quot;file&quot;</span><span style="color: #66cc66;">&#41;</span>
                        currentPhotoPath = SERVER_URL + leftTree.<span style="color: #006600;">selectedItem</span>.<span style="color: #66cc66;">@</span>path;
                    <span style="color: #b1b100;">else</span>
                        currentPhotoPath = <span style="color: #ff0000;">&quot;&quot;</span>;
                <span style="color: #808080; font-style: italic;">// if click is on the list</span>
                <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span>.<span style="color: #0066CC;">name</span> == <span style="color: #ff0000;">&quot;downloadList&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    currentPhotoPath = <span style="color: #66cc66;">&#40;</span>downloadList.<span style="color: #006600;">selectedItem</span> ? SERVER_URL + 
                                        downloadList.<span style="color: #006600;">selectedItem</span>.<span style="color: #006600;">path</span> : <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleKeyUp<span style="color: #66cc66;">&#40;</span>event:KeyboardEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function is used for deleting items from the list */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// if we have pressed the DELETE key and </span>
                <span style="color: #808080; font-style: italic;">// also there is at least one item selected</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">keyCode</span> == Keyboard.<span style="color: #0066CC;">DELETE</span> <span style="color: #66cc66;">&amp;&amp;</span> 
                        downloadList.<span style="color: #006600;">selectedIndex</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">var</span> removeItems:<span style="color: #0066CC;">Array</span> = downloadList.<span style="color: #006600;">selectedIndices</span>;
                    <span style="color: #808080; font-style: italic;">// remove selected items</span>
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> removeItems.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        downloadList.<span style="color: #006600;">dataProvider</span>.<span style="color: #006600;">removeItemAt</span><span style="color: #66cc66;">&#40;</span>removeItems<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #66cc66;">&#125;</span>
                    currentPhotoPath = <span style="color: #ff0000;">&quot;&quot;</span>;
                    <span style="color: #808080; font-style: italic;">// if the list is empty we disable the download button</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>downloadList.<span style="color: #006600;">dataProvider</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&lt;</span>= <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                        downloadButton.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> initializeDownload<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function starts the download 
                   we use FileReference to download */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// get the items dragged in the list</span>
                <span style="color: #000000; font-weight: bold;">var</span> paths:ArrayCollection = 
                    downloadList.<span style="color: #006600;">dataProvider</span> as ArrayCollection;
                <span style="color: #808080; font-style: italic;">// initialize the query/url string</span>
                <span style="color: #000000; font-weight: bold;">var</span> qStr:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
                <span style="color: #808080; font-style: italic;">// compose the query/url string</span>
                <span style="color: #808080; font-style: italic;">// we are sending an array to the server</span>
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> paths.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
                    qStr += <span style="color: #ff0000;">&quot;&amp;name[]=&quot;</span>+escape<span style="color: #66cc66;">&#40;</span>paths<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">path</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// get the file</span>
                <span style="color: #808080; font-style: italic;">// the file download.php on the server gets the array</span>
                <span style="color: #808080; font-style: italic;">// and in the memory creates an tgz archive</span>
                <span style="color: #808080; font-style: italic;">// and sends it back as being a file (using http headers)</span>
                <span style="color: #808080; font-style: italic;">// we are using FileReference for this</span>
                fRef.<span style="color: #006600;">download</span><span style="color: #66cc66;">&#40;</span>
                    <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>SERVER_URL + <span style="color: #ff0000;">&quot;download.php?&quot;</span> + qStr<span style="color: #66cc66;">&#41;</span>,
                    <span style="color: #ff0000;">&quot;archive.tgz&quot;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> doEvent<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* Function is displaying events reached when downloading 
                   For debug purposes */</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">var</span> fr:FileReference = evt.<span style="color: #006600;">currentTarget</span> as FileReference;   
                <span style="color: #808080; font-style: italic;">// for debug purposes */</span>
                <span style="color: #808080; font-style: italic;">//trace(&quot;type:&quot;+evt.type+&quot;, eventString:&quot;+evt.toString()); </span>
                <span style="color: #808080; font-style: italic;">//trace(fr.creationDate);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.creator);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.modificationDate);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.name);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.size);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.type);</span>
            <span style="color: #66cc66;">&#125;</span> 		
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> refresh<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* Function is refresing both the tree and the list and 
                   disables the download button */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// empty the list</span>
                fileListProvider = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// disable the download button</span>
                downloadButton.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
                <span style="color: #808080; font-style: italic;">// refresh the tree</span>
                dir.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</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><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>This is it! As I just wrote at the beginning of the article, the power and beauty of Flex framework is that you can do great things with a few lines of codding. So enjoy Flex!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Deleting Nodes Recursively from XML Structures</title>
		<link>http://www.flexer.info/2008/01/29/deleting-nodes-recursively-from-xml-structures/</link>
		<comments>http://www.flexer.info/2008/01/29/deleting-nodes-recursively-from-xml-structures/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 17:05:08 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://www.flexer.info/2008/01/29/deleting-nodes-recursively-from-xml-structures/</guid>
		<description><![CDATA[One thing, among others, that Flex doesn&#8217;t have, and is important because many of its components needs XML structures, is deleting (taking out) nodes from a XML structure. This is crucial for a tree or for a menu where you need to change it dynamically. So bellow is a recursive method that will go through [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F01%2F29%2Fdeleting-nodes-recursively-from-xml-structures%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F01%2F29%2Fdeleting-nodes-recursively-from-xml-structures%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/01/29/deleting-nodes-recursively-from-xml-structures/&title=Deleting+Nodes+Recursively+from+XML+Structures&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>One thing, among others, that Flex doesn&#8217;t have, and is important because many of its components needs XML structures, is deleting (taking out) nodes from a XML structure. This is crucial for a tree or for a menu where you need to change it dynamically. So bellow is a recursive method that will go through the whole XML and will remove the nodes specified in an array.</p>
<p>In <strong>goThrough</strong> method nodes are searched by the <strong>id_data</strong> XML attribute but with some minor changes you can make it search for node name.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> menubarXML:<span style="color: #0066CC;">XML</span> =
<span style="color: #66cc66;">&lt;</span>root<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;new&quot;</span> id_data=<span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;file&quot;</span> id_data=<span style="color: #ff0000;">&quot;file&quot;</span><span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;document&quot;</span> id_data=<span style="color: #ff0000;">&quot;document&quot;</span><span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;folder&quot;</span> id_data=<span style="color: #ff0000;">&quot;folder&quot;</span> <span style="color: #0066CC;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;other&quot;</span> id_data=<span style="color: #ff0000;">&quot;other&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>menuitem<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;edit&quot;</span> id_data=<span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;undo&quot;</span> id_data=<span style="color: #ff0000;">&quot;undo&quot;</span><span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;redo&quot;</span> id_data=<span style="color: #ff0000;">&quot;redo&quot;</span><span style="color: #66cc66;">/&gt;</span>	            
        <span style="color: #66cc66;">&lt;</span>menuitem <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;separator&quot;</span><span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;cut&quot;</span> id_data=<span style="color: #ff0000;">&quot;cut&quot;</span><span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;copy&quot;</span> id_data=<span style="color: #ff0000;">&quot;copy&quot;</span><span style="color: #66cc66;">/&gt;</span>	            
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;paste&quot;</span> id_data=<span style="color: #ff0000;">&quot;paste&quot;</span><span style="color: #66cc66;">/&gt;</span>	
        <span style="color: #66cc66;">&lt;</span>menuitem <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;separator&quot;</span><span style="color: #66cc66;">/&gt;</span>            	            
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;delete&quot;</span> id_data=<span style="color: #ff0000;">&quot;delete&quot;</span><span style="color: #66cc66;">/&gt;</span>	                                  
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;refresh&quot;</span> id_data=<span style="color: #ff0000;">&quot;refresh&quot;</span><span style="color: #66cc66;">/&gt;</span>	                                  
    <span style="color: #66cc66;">&lt;/</span>menuitem<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;help&quot;</span> id_data=<span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;help&quot;</span> id_data=<span style="color: #ff0000;">&quot;help&quot;</span><span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;search&quot;</span> id_data=<span style="color: #ff0000;">&quot;search&quot;</span><span style="color: #66cc66;">/&gt;</span>	            
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;about&quot;</span> id_data=<span style="color: #ff0000;">&quot;about&quot;</span><span style="color: #66cc66;">/&gt;</span> 
    <span style="color: #66cc66;">&lt;/</span>menuitem<span style="color: #66cc66;">&gt;</span>	        
    <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;logoff&quot;</span> id_data=<span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span> 
        <span style="color: #66cc66;">&lt;</span>menuitem label=<span style="color: #ff0000;">&quot;logoff&quot;</span> id_data=<span style="color: #ff0000;">&quot;logoff&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>menuitem<span style="color: #66cc66;">&gt;</span>	 	        
<span style="color: #66cc66;">&lt;/</span>root<span style="color: #66cc66;">&gt;</span>;	
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> goThrough<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span>:XMLList, removeData:<span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</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: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">xml</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - <span style="color: #cc66cc;">1</span>; i <span style="color: #66cc66;">&gt;</span>= <span style="color: #cc66cc;">0</span> ; i--<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>removeData.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #66cc66;">@</span>id_data.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #cc66cc;">1</span><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>i<span style="color: #66cc66;">&#93;</span>;
            <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</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: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">children</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>
                    goThrough<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">xml</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,removeData<span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The method is called like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">goThrough<span style="color: #66cc66;">&#40;</span>menubarXML.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'document'</span>,<span style="color: #ff0000;">'delete'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>and by accessing <strong>menubarXML</strong> afterwards you&#8217;ll have the XML with the specified nodes &mdash; having <strong>&#8220;document&#8221;</strong> and <strong>&#8220;delete&#8221;</strong> in <strong>id_data</strong> attribute &mdash; removed. This is working very smoothly because Flex uses, mainly, the Singleton pattern and most complex data is accessed by memory reference and this enables us that after modifying  <strong>menubarXML</strong> we will have its structure modified although this was done &#8220;locally&#8221; inside a method. The <strong>debugText</strong> is a TextArea for output and in this case the taken out nodes are displayed.</p>
<p>So this is it and I think will help many of you a lot. We are waiting for comments and you may improve it to suit your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/01/29/deleting-nodes-recursively-from-xml-structures/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

