<?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>Hangun's World - Blog &#187; XML</title>
	<atom:link href="http://hangunsworld.com/blog/tag/xml/feed" rel="self" type="application/rss+xml" />
	<link>http://hangunsworld.com/blog</link>
	<description>about ActionScript, Flash, Web and more...</description>
	<lastBuildDate>Wed, 01 Feb 2012 01:36:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>XML에 어트리뷰트 추가하기</title>
		<link>http://hangunsworld.com/blog/1144</link>
		<comments>http://hangunsworld.com/blog/1144#comments</comments>
		<pubDate>Tue, 06 Dec 2011 12:02:42 +0000</pubDate>
		<dc:creator>Hangun's World</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Attribute]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://hangunsworld.com/blog/?p=1144</guid>
		<description><![CDATA[XML에 차일드 노드를 추가하는 것은 XML.appendChild() 메소드를 사용하면 되는데, 공식적으로 속성(attribute)을 추가하는 메소드는 없습니다. 그래서 구글로 검색해 보니, 다음과 같은 방법으로 간단히 속성을 추가할 수가 있네요. var xml:XML = new XML&#40;&#60;root /&#62;&#41;; xml.@newAtrb = &#34;value&#34;; trace&#40;xml.toXMLString&#40;&#41;&#41;; // output: &#60;root newAtrb=&#34;value&#34;/&#62;]]></description>
			<content:encoded><![CDATA[<p>XML에 차일드 노드를 추가하는 것은 XML.appendChild() 메소드를 사용하면 되는데, 공식적으로 속성(attribute)을 추가하는 메소드는 없습니다.</p>
<p>그래서 구글로 검색해 보니, 다음과 같은 방법으로 간단히 속성을 추가할 수가 있네요.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">&lt;</span>root <span style="color: #000066; font-weight: bold;">/&gt;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
xml<span style="color: #000066; font-weight: bold;">.</span>@newAtrb = <span style="color: #990000;">&quot;value&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toXMLString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// output: &lt;root newAtrb=&quot;value&quot;/&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://hangunsworld.com/blog/1144/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>플래시와 XML 인코딩이 다른 경우 데이터 로드하기</title>
		<link>http://hangunsworld.com/blog/396</link>
		<comments>http://hangunsworld.com/blog/396#comments</comments>
		<pubDate>Fri, 07 Nov 2008 04:02:31 +0000</pubDate>
		<dc:creator>Hangun's World</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Character Set]]></category>
		<category><![CDATA[Encoding]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[URLStream]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLLoader]]></category>

		<guid isPermaLink="false">http://hangunsworld.com/blog/?p=396</guid>
		<description><![CDATA[보통 AS3에서 외부 데이터를 로드하기 위해서 URLLoader를 많이 사용합니다. 그런데 플래시의 인코딩 설정과 로드할 XML 또는 텍스트 파일의 인코딩 설정이 다른 경우에 2바이트 언어의 문자가 깨져서 들어오죠. 그래서 System.useCodePage 설정을 바꿔주거나, 텍스트 파일의 인코딩을 변경하거나 둘 중 하나를 해 주어야 합니다. 뭐 좀 귀찮지만, 여기까진 문제가 없죠. 그런데, 만약, 서로 다른 인코딩의 텍스트 파일 2개 <a href='http://hangunsworld.com/blog/396'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>보통 AS3에서 외부 데이터를 로드하기 위해서 URLLoader를 많이 사용합니다. 그런데 플래시의 인코딩 설정과 로드할 XML 또는 텍스트 파일의 인코딩 설정이 다른 경우에 2바이트 언어의 문자가 깨져서 들어오죠. 그래서 System.useCodePage 설정을 바꿔주거나, 텍스트 파일의 인코딩을 변경하거나 둘 중 하나를 해 주어야 합니다. 뭐 좀 귀찮지만, 여기까진 문제가 없죠.</p>
<p>그런데, 만약, 서로 다른 인코딩의 텍스트 파일 2개 이상을 동시에 로드해야 하는 경우라면 OTL 이죠. 이럴 때 XMLLoader를 사용하면 문제가 말끔히 사라집니다. ^^</p>
<p><strong>상황 1</strong><br />
플래시 EUC-KR &#8212;&#8211; 텍스트 UTF-8<br />
XMLLoader.load(UR [,"utf-8"]);==> 한글 정상 표시<br />
URLLoader.load(UR) ==> 한글 깨짐<br />
(UR은 URLRequest 객체)</p>
<p><strong>상황2</strong><br />
플래시 UTF-8 &#8212;&#8211; 텍스트 EUC-KR<br />
XMLLoader.load(UR, &#8220;euc-kr&#8221;) ==> 한글 정상 표시<br />
URLLoader.load(UR) ==> 한글 깨짐</p>
<p><strong>상황3</strong><br />
플래시 UTF-8 &#8212;&#8211; 텍스트1 UTF-8, 텍스트2 EUC-KR<br />
XMLLoader.load(UR1 [, "utf-8"]) ==> 한글 정상 표시<br />
XMLLoader.load(UR2, &#8220;euc-kr&#8221;) ==> 한글 정상 표시<br />
URLLoader.load(UR1) ==> 한글 정상 표시<br />
URLLoader.load(UR2) ==> 한글 깨짐</p>
<p>XMLLoader는 내부적으로 URLStream을 사용하는 것으로, URLLoader 대신 URLStream 을 사용하여도 같은 효과를 얻을 수 있습니다.</p>
<p>참고  URL: <a href="http://hangunsworld.com/blog/259">http://hangunsworld.com/blog/259</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hangunsworld.com/blog/396/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>The XMLLoader class has been revised.</title>
		<link>http://hangunsworld.com/blog/259</link>
		<comments>http://hangunsworld.com/blog/259#comments</comments>
		<pubDate>Mon, 31 Mar 2008 01:05:24 +0000</pubDate>
		<dc:creator>Hangun's World</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Character Set]]></category>
		<category><![CDATA[URLStream]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLLoader]]></category>

		<guid isPermaLink="false">http://hangunsworld.com/blog/259</guid>
		<description><![CDATA[기존에 try&#8230;catch 구문을 이용해서 만들었던 XMLLoader(XMLLoaderOld로 변경)는 몇 가지 문제점들을 포함하고 있었습니다. Wooyaggo님이 URLStream 객체를 사용하여 만든 XMLLoader 클래스를 보고서 저도 URLStream 객체를 사용하도록 수정해 보았습니다. XMLLoader 파일 다운로드 그런데 이벤트 관련해서 이런식으로 사용하는 것이 옳은 것인지 모르겠네요. 많은 지적 부탁드립니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <a href='http://hangunsworld.com/blog/259'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>기존에 try&#8230;catch 구문을 이용해서 만들었던 <a href="http://hangunsworld.com/blog/236">XMLLoader</a>(XMLLoaderOld로 변경)는 몇 가지 문제점들을 포함하고 있었습니다. <a href="http://wooyaggo.tistory.com/">Wooyaggo</a>님이 URLStream 객체를 사용하여 만든 <a href="http://wooyaggo.tistory.com/116">XMLLoader 클래스</a>를 보고서 저도 URLStream 객체를 사용하도록 수정해 보았습니다.</p>
<p><a href="http://hangunsworld.com/classes/com/hangunsworld/net/XMLLoader">XMLLoader 파일 다운로드</a></p>
<p>그런데 이벤트 관련해서 이런식으로 사용하는 것이 옳은 것인지 모르겠네요. 많은 지적 부탁드립니다.</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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
 * XMLLoader
 * XMLLoader class loads an external text file and decodes the data with the provided character set.
 * If you loads a text file encoded in the euc-kr encoding via an URLLoader, frequently, the source data is currupted.
 * To avoid this problem, uses URLStream instead of URLLoader.
 *
 * XMLLoader is the modified version of the XMLLoaderOld class.
 * This code is inspired by Wooyaggo's article(http://wooyaggo.tistory.com/116).
 * 
 *
 * @author: Han Sanghun (http://hangunsworld.com, hanguns@gmail.com)
 * @created: 2008 03 28
 * @last modified: 2008 06 06
 */</span>
&nbsp;
 <span style="color: #3f5fbf;">/*
Licensed under the MIT License
&nbsp;
Copyright (c) 2008 Han Sanghun
&nbsp;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the &quot;Software&quot;), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
&nbsp;
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
&nbsp;
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
&nbsp;
http://hangunsworld.com/classes/com/hangunsworld/net/
*/</span>
&nbsp;
<span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>hangunsworld<span style="color: #000066; font-weight: bold;">.</span>net<span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLLoader</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">URLStream</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> XMLLoader<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> us<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLStream</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ul<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ur<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> encode<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * XMLLoader constructor
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> XMLLoader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
			us = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			ul = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end constructor</span>
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Adds event listeners to the URLLoader object and the URLStream object.
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> listener<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span><span style="color: #000066; font-weight: bold;">,</span> useCapture<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> priority<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> useWeakReference<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			ul<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">,</span> listener<span style="color: #000066; font-weight: bold;">,</span> useCapture<span style="color: #000066; font-weight: bold;">,</span> priority<span style="color: #000066; font-weight: bold;">,</span> useWeakReference<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			us<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">,</span> agentListener<span style="color: #000066; font-weight: bold;">,</span> useCapture<span style="color: #000066; font-weight: bold;">,</span> priority<span style="color: #000066; font-weight: bold;">,</span> useWeakReference<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end addEventListener</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Removes event listeners from the URLLoader object and the URLStream object.
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> listener<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span><span style="color: #000066; font-weight: bold;">,</span> useCapture<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			ul<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">,</span> listener<span style="color: #000066; font-weight: bold;">,</span> useCapture<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			us<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">,</span> agentListener<span style="color: #000066; font-weight: bold;">,</span> useCapture<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end removeEventListener</span>
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Loads external data via the URLStream object,
		 * and sets the character set with the provied string.
		 *
		 * @param pUr The URLRequest object.
		 * @param pEncode The string denoting the character set to use to interpret the bytes. [OPTIONAL]
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>pUr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">,</span> pEncode<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span>=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
			encode = pEncode<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			ur = pUr<span style="color: #000066; font-weight: bold;">;</span>
			us<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>ur<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end load</span>
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Dispatches events through the URLLoader object.
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> agentListener<span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">type</span> == <span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #009900; font-style: italic;">// If the event's type is Event.COMPLETE, decodes the loaded data using the provided character set.</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = us<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">readMultiByte</span><span style="color: #000000;">&#40;</span>us<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesAvailable</span><span style="color: #000066; font-weight: bold;">,</span> encode<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #009900; font-style: italic;">// Puts the decoded data into the URLLoader object.</span>
				<span style="color: #004993;">data</span> = str<span style="color: #000066; font-weight: bold;">;</span>
				ul<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> = str<span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			ul<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end agentListener</span>
&nbsp;
&nbsp;
	<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end class</span>
<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end package</span></pre></td></tr></table></div>

<p>Usage example.</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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span>	com<span style="color: #000066; font-weight: bold;">.</span>hangunsworld<span style="color: #000066; font-weight: bold;">.</span>net<span style="color: #000066; font-weight: bold;">.</span>XMLLoader<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> xloader<span style="color: #000066; font-weight: bold;">:</span>XMLLoader = <span style="color: #0033ff; font-weight: bold;">new</span> XMLLoader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
xloader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> loaded<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
xloader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">IO_ERROR</span><span style="color: #000066; font-weight: bold;">,</span> errored<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
xloader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PROGRESS</span><span style="color: #000066; font-weight: bold;">,</span> progressed<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
xloader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span>path<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;euc-kr&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> loaded<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;COMPLETE&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span>xloader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> errored<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;IOERROR&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> progressed<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;PROGRESS - &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesTotal</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; : &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesLoaded</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hangunsworld.com/blog/259/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>XMLLoader, a custom class.</title>
		<link>http://hangunsworld.com/blog/236</link>
		<comments>http://hangunsworld.com/blog/236#comments</comments>
		<pubDate>Wed, 27 Feb 2008 19:20:21 +0000</pubDate>
		<dc:creator>Hangun's World</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://hangunsworld.com/blog/236</guid>
		<description><![CDATA[I devised the XMLLoader class to avoid the URLLoader bug that I posted on FlaLab.com. Related links 예전에 FlaLab에 올렸던 URLLoader의 버그를 회피하기 위해서 만든 XMLLoader 클래스 입니다. 참고 링크 私がFlaLab.comに書いたURLLoaderのバーグを回避するためにXMLLoaderクラスを作りました。 参考リンク http://www.flalab.com/phpBB2/viewtopic.php?t=1791 http://www.flalab.com/phpBB2/viewtopic.php?t=2228 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 <a href='http://hangunsworld.com/blog/236'>[...]</a>]]></description>
			<content:encoded><![CDATA[<div class="english">I devised the XMLLoader class to avoid the URLLoader bug that I posted on FlaLab.com.<br />
Related links</div>
<div class="korean">예전에 FlaLab에 올렸던 URLLoader의 버그를 회피하기 위해서 만든 XMLLoader 클래스 입니다.<br />
참고 링크</div>
<div class="japanese">私がFlaLab.comに書いたURLLoaderのバーグを回避するためにXMLLoaderクラスを作りました。<br />
参考リンク</div>
<p><a href="http://www.flalab.com/phpBB2/viewtopic.php?t=1791">http://www.flalab.com/phpBB2/viewtopic.php?t=1791</a><br />
<a href="http://www.flalab.com/phpBB2/viewtopic.php?t=2228">http://www.flalab.com/phpBB2/viewtopic.php?t=2228</a></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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
 * XMLLoader
 *
 * XMLLoader class loads and validates an XML file.
 * If you loads a text file encoded in the euc-kr encoding via an URLLoader, frequently, the source data is currupted.
 * To avoid this problem, parses the loaded data into an XMLDocument,
 * then, parses the first node of the XMLDocument into an XML.
 * If an error has been occured, reloads the XML data.
 * 
 *
 * @author: Han Sanghun (http://hangunsworld.com, hanguns@gmail.com)
 * @created: 2008 02 28
 * @last modified: 2008 02 29
 */</span>
&nbsp;
&nbsp;
<span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>hangunsworld<span style="color: #000066; font-weight: bold;">.</span>as3<span style="color: #000066; font-weight: bold;">.</span>net<span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Timer</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span>	<span style="color: #004993;">flash.xml</span><span style="color: #000066; font-weight: bold;">.*;</span>
&nbsp;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> XMLLoader<span style="color: #000000;">&#123;</span>
&nbsp;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> path<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> returnFunction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> errorFunction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Timer</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> xml_ul<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> xml_ur<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> xml_uv<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLVariables</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * XMLLoader constructor
		 *
		 * @param pPath A path of an XML file
		 * @param okFunc A function to call when the XML is loaded successfully
		 * @param errorFunc A function to call when an IOError has occured
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> XMLLoader<span style="color: #000000;">&#40;</span>pPath<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> okFunc<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span> errorFunc<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Function</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
			path = pPath<span style="color: #000066; font-weight: bold;">;</span>
			returnFunction = okFunc<span style="color: #000066; font-weight: bold;">;</span>
			errorFunction = errorFunc
&nbsp;
			<span style="color: #004993;">XML</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ignoreWhitespace</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">XML</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ignoreComments</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
			<span style="color: #009900; font-style: italic;">// Initializes NET objects</span>
			xml_ul = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			xml_ul<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> xmlCompleteListener<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			xml_ul<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">IO_ERROR</span><span style="color: #000066; font-weight: bold;">,</span> errorListener<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			xml_ur = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			xml_ur<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span> = path<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			xml_uv = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLVariables</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
			<span style="color: #009900; font-style: italic;">// Initializes Timer object</span>
			<span style="color: #004993;">timer</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Timer</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">TimerEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TIMER</span><span style="color: #000066; font-weight: bold;">,</span> timerListener<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end constructor</span>
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Timer EventListener
		 * Loads an XML file after some time
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> timerListener<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">TimerEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			loadXML<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end timerListener</span>
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Loads an XML file
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> loadXML<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>path<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;?&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #009900; font-style: italic;">// If the url already contains parameters, attaches the random seed to the end of the url</span>
				xml_ur<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span> = path <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;&amp;randomSeed=&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">1000000</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
				<span style="color: #009900; font-style: italic;">// If the url does not contain parameters, uses an URLVariable object</span>
				xml_uv<span style="color: #000066; font-weight: bold;">.</span>randomSeed = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">1000000</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				xml_ur<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> = xml_uv<span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			xml_ul<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span> <span style="color: #000000;">&#40;</span>xml_ur<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end loadXML</span>
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * XML Complete EventListener
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> xmlCompleteListener<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Sets the defualt parse state to false</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> parsed<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = evt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> xmldoc<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XMLDocument</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XMLDocument</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			xmldoc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ignoreWhite</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">try</span><span style="color: #000000;">&#123;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">// Parses the loaded data into an XMLDocument</span>
				xmldoc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">parseXML</span><span style="color: #000000;">&#40;</span>str<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">// Gets a string from the first node of the XMLDocument</span>
				str = xmldoc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">firstChild</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">// Parses the string into an XML</span>
				xml = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span>str<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">// If no error has occured, sets the parse stae to true</span>
				parsed = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">catch</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
				<span style="color: #009900; font-style: italic;">// If an error occured, loads the XML again</span>
				<span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end try catch</span>
&nbsp;
&nbsp;
			<span style="color: #009900; font-style: italic;">// If the parse process done without errors and the returnFunction is NOT null, returns the XML data</span>
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>parsed<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>returnFunction <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
					returnFunction<span style="color: #000000;">&#40;</span>xml<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end xmlCompleteListener</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * XML IOError EventListener
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> errorListener<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>errorFunction <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				errorFunction<span style="color: #000000;">&#40;</span>evt<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end xmlErrorListener</span>
&nbsp;
&nbsp;
	<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end class</span>
&nbsp;
<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// end package</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span>	com<span style="color: #000066; font-weight: bold;">.</span>hangunsworld<span style="color: #000066; font-weight: bold;">.</span>as3<span style="color: #000066; font-weight: bold;">.</span>net<span style="color: #000066; font-weight: bold;">.</span>XMLLoader<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> xloader<span style="color: #000066; font-weight: bold;">:</span>XMLLoader<span style="color: #000066; font-weight: bold;">;</span>
xloader = <span style="color: #0033ff; font-weight: bold;">new</span> XMLLoader<span style="color: #000000;">&#40;</span>xmlPath<span style="color: #000066; font-weight: bold;">,</span> xmlLoaded<span style="color: #000066; font-weight: bold;">,</span> xmlErrorListener<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> xmlLoaded<span style="color: #000000;">&#40;</span>xx<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">// xml loaded</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> xmlErrorListener<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;xml load error&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://hangunsworld.com/blog/236/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

