<?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; Testing</title>
	<atom:link href="http://www.flexer.info/category/testing/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>Resources Used @ Bootcamps Are Available</title>
		<link>http://www.flexer.info/2009/05/25/resources-used-bootcamps-are-available/</link>
		<comments>http://www.flexer.info/2009/05/25/resources-used-bootcamps-are-available/#comments</comments>
		<pubDate>Mon, 25 May 2009 11:59:39 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex resources]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[resources]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=778</guid>
		<description><![CDATA[First of all the bootcamps were a success if we think about that all tickets were sold out before the Adobe Developer Day started. The resources used at three of bootcamps held at Adobe Developer Day are now available by the evangelists Cornel Creanga and Mihai Corlan on their blogs. 
Using the following links you [...]]]></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%2F2009%2F05%2F25%2Fresources-used-bootcamps-are-available%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2009%2F05%2F25%2Fresources-used-bootcamps-are-available%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/2009/05/25/resources-used-bootcamps-are-available/&title=Resources+Used+@+Bootcamps+Are+Available&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>First of all the bootcamps were a success if we think about that all tickets were sold out before the <a href="http://www.flexer.info/2009/05/20/adobe-developer-day-bucharest-we-were-there/" target="_blank">Adobe Developer Day</a> started. The resources used at three of bootcamps held at Adobe Developer Day are now available by the evangelists <a href="http://cornelcreanga.com" target="_blank">Cornel Creanga</a> and <a href="http://corlan.org/" target="_blank">Mihai Corlan</a> on their blogs. </p>
<p>Using the following links you can directly download the resources you need: </p>
<ul class="ul">
<li>Introduction to Flex and AIR Bootcamp<br />
<a href="http://corlan.org/bootcamp/AIRBootCamp.zip" target="_blank">http://corlan.org/bootcamp/AIRBootCamp.zip</a><br />
<a href="http://corlan.org/bootcamp/BootCamp_Introduction_to_AIR.pdf" target="_blank">http://corlan.org/bootcamp/BootCamp_Introduction_to_AIR.pdf</a>
</li>
<li>BlazeDS + LCDS Bootcamp Advanced<br />
<a href="http://cornelcreanga.com/docs/bootcamp.zip" target="_blank">http://cornelcreanga.com/docs/bootcamp.zip</a>
</li>
<li>Micro-architecture of Enterprise Applications<br />
<a href="http://corlan.org/bootcamp/MicroArchitecturesProjects.zip" target="_blank">http://corlan.org/bootcamp/MicroArchitecturesProjects.zip</a><br />
<a href="http://corlan.org/bootcamp/MicroArchitecture2.pdf" target="_blank">http://corlan.org/bootcamp/MicroArchitecture2.pdf</a>
</li>
</ul>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2009/05/25/resources-used-bootcamps-are-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Events Dispatch Order</title>
		<link>http://www.flexer.info/2008/09/12/image-events-dispatch-order/</link>
		<comments>http://www.flexer.info/2008/09/12/image-events-dispatch-order/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 10:20:31 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[MXML]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=254</guid>
		<description><![CDATA[Yesterday I&#8217;ve been working with images: loading, resizing, removing, etc. I got into a challenging issue: I had to vertically position a label after an image resize &#8211; but a resize that is triggered by setting maxWidth and maxHeight keeping also the aspect ratio.
I tried to get the new width and height after the resize [...]]]></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%2F12%2Fimage-events-dispatch-order%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F09%2F12%2Fimage-events-dispatch-order%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/12/image-events-dispatch-order/&title=Image+Events+Dispatch+Order&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>Yesterday I&#8217;ve been working with images: loading, resizing, removing, etc. I got into a challenging issue: I had to vertically position a label after an image resize &#8211; but a resize that is triggered by setting <strong>maxWidth </strong>and <strong>maxHeight</strong> keeping also the aspect ratio.</p>
<p>I tried to get the new width and height after the resize event was triggered but no luck. I&#8217;ve been debugging a while and seen that the new width and the new height are in <strong>$height</strong> and <strong>$width</strong> internal variables. I had no luck getting the new width and the new height in this method triggered by the resize event.</p>
<p>So I started to investigate to see which event triggers the last that way making it sure all properties are updated. I created a simple application that will load an arbitrary image in mean time displaying the events triggered. There is also a button that moves the image horizontally by 50 pixels also showing the triggered events.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_imageeventstest_1019996054"
			class="flashmovie"
			width="600"
			height="615">
	<param name="movie" value="/wp-content/uploads/2008/09/imageeventstest.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/09/imageeventstest.swf"
			name="fm_imageeventstest_1019996054"
			width="600"
			height="615">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
I found that after resize event update complete event triggers which contains the needed width and height in <strong>contentWidth </strong>and <strong>contentHeight </strong>properties.</p>
<p>I hope this will help you in different scenarios you&#8217;ll encounter in development.</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
</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>
    applicationComplete=<span style="color: #ff0000;">&quot;start()&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;600&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;615&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;imageUrl&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;383&quot;</span> 
        <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;http://www.flexer.info/wp-content/gallery/wallpapers/fxr_1600x1200.png&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;401&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span>  label=<span style="color: #ff0000;">&quot;Start&quot;</span> 
        click=<span style="color: #ff0000;">&quot;handleButtonClick(event)&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;464&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span>  label=<span style="color: #ff0000;">&quot;Move it&quot;</span> 
        click=<span style="color: #ff0000;">&quot;handleMoveButtonClick(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Image id=<span style="color: #ff0000;">&quot;testImage&quot;</span> maxWidth=<span style="color: #ff0000;">&quot;250&quot;</span> maxHeight=<span style="color: #ff0000;">&quot;250&quot;</span> 
        x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span>
        addedToStage=<span style="color: #ff0000;">&quot;handleAddedToStage(event)&quot;</span>
        complete=<span style="color: #ff0000;">&quot;handleComplete(event)&quot;</span>
        creationComplete=<span style="color: #ff0000;">&quot;handleCreationComplete(event)&quot;</span>
        currentStateChange=<span style="color: #ff0000;">&quot;handleCurrentStateChange(event)&quot;</span>
        init=<span style="color: #ff0000;">&quot;handleInit(event)&quot;</span>
        initialize=<span style="color: #ff0000;">&quot;handleInitialize(event)&quot;</span>
        open=<span style="color: #ff0000;">&quot;handleOpen(event)&quot;</span>
        preinitialize=<span style="color: #ff0000;">&quot;handlePreinitialize(event)&quot;</span>
        progress=<span style="color: #ff0000;">&quot;handleProgress(event)&quot;</span>
        removed=<span style="color: #ff0000;">&quot;handleRemoved(event)&quot;</span>
        render=<span style="color: #ff0000;">&quot;handleRender(event)&quot;</span>
        resize=<span style="color: #ff0000;">&quot;handleResize(event)&quot;</span>
        <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">&quot;handleShow(event)&quot;</span>
        unload=<span style="color: #ff0000;">&quot;handleUnload(event)&quot;</span>
        updateComplete=<span style="color: #ff0000;">&quot;handleUpdateComplete(event)&quot;</span>
        valid=<span style="color: #ff0000;">&quot;handleValid(event)&quot;</span>
        valueCommit=<span style="color: #ff0000;">&quot;handleValueCommit(event)&quot;</span>
        <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextArea x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;300&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;580&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;305&quot;</span> 
        <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{_debug}&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;">events</span>.<span style="color: #006600;">ResizeEvent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">StateChangeEvent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlexEvent</span>;
&nbsp;
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _debug:<span style="color: #0066CC;">String</span>;
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug = <span style="color: #ff0000;">&quot;---&gt; application started!!!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleButtonClick<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>
                testImage.<span style="color: #006600;">source</span> = imageUrl.<span style="color: #0066CC;">text</span>;
                _debug += <span style="color: #ff0000;">&quot;---&gt; handleButtonClick<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleMoveButtonClick<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>
                testImage.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">50</span>;
                _debug += <span style="color: #ff0000;">&quot;---&gt; handleMoveButtonClick<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAddedToStage<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>
                _debug += <span style="color: #ff0000;">&quot;handleAddedToStage<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleComplete<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>
                _debug += <span style="color: #ff0000;">&quot;adddedToStage<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleCreationComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleCreationComplete<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleCurrentStateChange<span style="color: #66cc66;">&#40;</span>
                <span style="color: #0066CC;">e</span>:StateChangeEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleCurrentStateChange<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleInit<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>
                _debug += <span style="color: #ff0000;">&quot;handleInit<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleInitialize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleInitialize<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleOpen<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>
                _debug += <span style="color: #ff0000;">&quot;handleOpen<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handlePreinitialize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handlePreinitialize<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleProgress<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ProgressEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleProgress<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleRemoved<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>
                _debug += <span style="color: #ff0000;">&quot;handleRemoved<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleRender<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>
                _debug += <span style="color: #ff0000;">&quot;handleRender<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleResize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ResizeEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleResize<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleShow<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleShow<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleUnload<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>
                _debug += <span style="color: #ff0000;">&quot;handleUnload<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleUpdateComplete<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>
                _debug += <span style="color: #ff0000;">&quot;handleUpdateComplete<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
                _debug += <span style="color: #ff0000;">&quot;     contentHeight: &quot;</span> + 
                    <span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">contentHeight</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
                _debug += <span style="color: #ff0000;">&quot;     x: &quot;</span> + <span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">x</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleValid<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleValid<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleValueCommit<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleValueCommit<span style="color: #000099; font-weight: bold;">\n</span>&quot;</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 hope you won&#8217;t be offended by the fact that I created one event method for each event type instead of having just one method and &#8220;switching&#8221; for the type inside it. <img src='http://www.flexer.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/09/12/image-events-dispatch-order/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AS3 Memory Monitoring/Usage</title>
		<link>http://www.flexer.info/2008/05/06/as3-memory-monitoring-usage/</link>
		<comments>http://www.flexer.info/2008/05/06/as3-memory-monitoring-usage/#comments</comments>
		<pubDate>Tue, 06 May 2008 12:06:26 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[bytes]]></category>
		<category><![CDATA[leaks]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[usage]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=63</guid>
		<description><![CDATA[You can monitor your memory usage/leaking with System.totalMemory property. This way you can see how memory is used, where leaks are and you can optimize those parts that are eating too much memory.
In simple words use System.totalMemory as bellow (in KB):

var memoryUsedInKb:Number= Number&#40;System.totalMemory/1024&#41;.toFixed&#40;2&#41;;

I used it to show the used memory in different units: bytes, Kilobytes, [...]]]></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%2F06%2Fas3-memory-monitoring-usage%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F05%2F06%2Fas3-memory-monitoring-usage%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/06/as3-memory-monitoring-usage/&title=AS3+Memory+Monitoring/Usage&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>You can monitor your memory usage/leaking with <strong>System.totalMemory</strong> property. This way you can see how memory is used, where leaks are and you can optimize those parts that are eating too much memory.</p>
<p>In simple words use System.totalMemory as bellow (in KB):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> memoryUsedInKb:<span style="color: #0066CC;">Number</span>= <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">System</span>.<span style="color: #006600;">totalMemory</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toFixed</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>I used it to show the used memory in different units: bytes, Kilobytes, Megabytes, Terrabytes (I hope you&#8217;ll never reach TB in your developed applications &#8211; that will be a huge memory leak).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> calculateUsedBytes<span style="color: #66cc66;">&#40;</span>unit:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> p:uint = pows<span style="color: #66cc66;">&#91;</span>unit.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> t:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">System</span>.<span style="color: #006600;">totalMemory</span><span style="color: #66cc66;">/</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">pow</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,p<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">var</span> d:uint = digits<span style="color: #66cc66;">&#91;</span>unit.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;
    <span style="color: #b1b100;">return</span> t.<span style="color: #006600;">toFixed</span><span style="color: #66cc66;">&#40;</span>d<span style="color: #66cc66;">&#41;</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></pre></div></div>

<p>The whole code is at the end and now the application&#8230;<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_memory_used_1496946830"
			class="flashmovie"
			width="237"
			height="255">
	<param name="movie" value="/wp-content/uploads/2008/05/memory_used.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/05/memory_used.swf"
			name="fm_memory_used_1496946830"
			width="237"
			height="255">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
The code:</p>

<div class="wp_syntax"><div 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;237&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;255&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextInput x=<span style="color: #ff0000;">&quot;67&quot;</span> y=<span style="color: #ff0000;">&quot;131&quot;</span> id=<span style="color: #ff0000;">&quot;stringToRepeat&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;abcdefghijklmnopqrstuvw&quot;</span> 
        toolTip=<span style="color: #ff0000;">&quot;The string that will be added&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;9&quot;</span> y=<span style="color: #ff0000;">&quot;133&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;String:&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;9&quot;</span> y=<span style="color: #ff0000;">&quot;159&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Repeat:&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:NumericStepper x=<span style="color: #ff0000;">&quot;67&quot;</span> y=<span style="color: #ff0000;">&quot;157&quot;</span> id=<span style="color: #ff0000;">&quot;timesToRepeat&quot;</span> stepSize=<span style="color: #ff0000;">&quot;10&quot;</span> minimum=<span style="color: #ff0000;">&quot;0&quot;</span> 
        maximum=<span style="color: #ff0000;">&quot;1000000&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;99&quot;</span> toolTip=<span style="color: #ff0000;">&quot;How many times the string will be added&quot;</span> 
        value=<span style="color: #ff0000;">&quot;10000&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;174&quot;</span> y=<span style="color: #ff0000;">&quot;157&quot;</span> label=<span style="color: #ff0000;">&quot;+&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;22&quot;</span> click=<span style="color: #ff0000;">&quot;handleAlocate(event)&quot;</span> 
        toolTip=<span style="color: #ff0000;">&quot;Alocate&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;9&quot;</span> y=<span style="color: #ff0000;">&quot;203&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Memory:&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:HRule x=<span style="color: #ff0000;">&quot;9&quot;</span> y=<span style="color: #ff0000;">&quot;187&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;217&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;8&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:HRule x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;115&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;217&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;8&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;67&quot;</span> y=<span style="color: #ff0000;">&quot;203&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;159&quot;</span> id=<span style="color: #ff0000;">&quot;kbUsed&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{memoryUsed}&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:ComboBox x=<span style="color: #ff0000;">&quot;171&quot;</span> y=<span style="color: #ff0000;">&quot;201&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;55&quot;</span> id=<span style="color: #ff0000;">&quot;unitCombo&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{units}&quot;</span>
        change=<span style="color: #ff0000;">&quot;handleUnitChange(event)&quot;</span> toolTip=<span style="color: #ff0000;">&quot;Units&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;9&quot;</span> y=<span style="color: #ff0000;">&quot;229&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Length:&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{arrayLength}&quot;</span> x=<span style="color: #ff0000;">&quot;67&quot;</span> y=<span style="color: #ff0000;">&quot;229&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;87&quot;</span> 
        toolTip=<span style="color: #ff0000;">&quot;The length of the array containing the strings&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;204&quot;</span> y=<span style="color: #ff0000;">&quot;157&quot;</span> label=<span style="color: #ff0000;">&quot;x&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;22&quot;</span> click=<span style="color: #ff0000;">&quot;handleClear(event)&quot;</span> toolTip=<span style="color: #ff0000;">&quot;Clear&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Text</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">'This is an example to show memory usage. Use the string and 
        the repeat stepper to alocate more memory. Pressing &quot;+&quot; button will add the 
        string n times as selected into repeat to an array. The &quot;x&quot; button is for 
        clearing out the array.'</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;217&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;102&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: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> units:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;B&quot;</span>,<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;KB&quot;</span>,<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;K&quot;</span><span style="color: #66cc66;">&#125;</span>,
                <span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;MB&quot;</span>,<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;m&quot;</span><span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;TB&quot;</span>,<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;t&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> pows:<span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span>b:<span style="color: #cc66cc;">0</span>,k:<span style="color: #cc66cc;">10</span>,m:<span style="color: #cc66cc;">20</span>,t:<span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#125;</span>;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> digits:<span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span>b:<span style="color: #cc66cc;">0</span>,k:<span style="color: #cc66cc;">0</span>,m:<span style="color: #cc66cc;">2</span>,t:<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#125;</span>;
&nbsp;
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> memoryUsed:<span style="color: #0066CC;">String</span>;
&nbsp;
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> arrayLength:uint;
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> useDump:<span style="color: #0066CC;">Array</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: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #0066CC;">private</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>
                memoryUsed = calculateUsedBytes<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;k&quot;</span><span style="color: #66cc66;">&#41;</span>; 
                unitCombo.<span style="color: #006600;">selectedIndex</span> = <span style="color: #cc66cc;">1</span>;
                arrayLength = useDump.<span style="color: #0066CC;">length</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> calculateUsedBytes<span style="color: #66cc66;">&#40;</span>unit:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">var</span> p:uint = pows<span style="color: #66cc66;">&#91;</span>unit.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;
                <span style="color: #000000; font-weight: bold;">var</span> t:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">System</span>.<span style="color: #006600;">totalMemory</span><span style="color: #66cc66;">/</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">pow</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,p<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #000000; font-weight: bold;">var</span> d:uint = digits<span style="color: #66cc66;">&#91;</span>unit.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;
                <span style="color: #b1b100;">return</span> t.<span style="color: #006600;">toFixed</span><span style="color: #66cc66;">&#40;</span>d<span style="color: #66cc66;">&#41;</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> handleUnitChange<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                memoryUsed = calculateUsedBytes<span style="color: #66cc66;">&#40;</span>unitCombo.<span style="color: #006600;">selectedItem</span>.<span style="color: #0066CC;">data</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> handleAlocate<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: #000000; font-weight: bold;">var</span> r:uint = timesToRepeat.<span style="color: #006600;">value</span>;
                <span style="color: #000000; font-weight: bold;">var</span> s:<span style="color: #0066CC;">String</span> = stringToRepeat.<span style="color: #0066CC;">text</span>;
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> r; i++<span style="color: #66cc66;">&#41;</span>
                    useDump.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;
&nbsp;
                memoryUsed = calculateUsedBytes<span style="color: #66cc66;">&#40;</span>unitCombo.<span style="color: #006600;">selectedItem</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
                arrayLength = useDump.<span style="color: #0066CC;">length</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleClear<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>
                useDump = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
                memoryUsed = calculateUsedBytes<span style="color: #66cc66;">&#40;</span>unitCombo.<span style="color: #006600;">selectedItem</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
                arrayLength = useDump.<span style="color: #0066CC;">length</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <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></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/05/06/as3-memory-monitoring-usage/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Comparison: Remove Duplicate Chars from a String Via Array and RegExp</title>
		<link>http://www.flexer.info/2008/04/23/comparison-remove-duplicate-chars-from-a-string-via-array-and-regexp/</link>
		<comments>http://www.flexer.info/2008/04/23/comparison-remove-duplicate-chars-from-a-string-via-array-and-regexp/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 11:59:20 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[chars]]></category>
		<category><![CDATA[duplicate]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[unique]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=148</guid>
		<description><![CDATA[In the previous article, Remove Duplicate Chars from a String, I posted a way to remove duplicates characters from a string and make it of unique chars. So to make myself clear I&#8217;ll give the following example:
Source string: &#8220;aabbccaaddee&#8221;
Should be: &#8220;abcde&#8221;
(note the underlined characters).
In my previous article TLP has commented and created a better method. [...]]]></description>
			<content:encoded><![CDATA[<div class='series_toc'><h3>Table of contents<!-- for Remove Duplicate Chars --></h3><ol><li><a href='http://www.flexer.info/2008/03/11/remove-duplicate-chars-from-a-string/' title='Remove Duplicate Chars from a String'>Remove Duplicate Chars from a String</a></li><li>Comparison: Remove Duplicate Chars from a String Via Array and RegExp</li></ol></div> <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%2F04%2F23%2Fcomparison-remove-duplicate-chars-from-a-string-via-array-and-regexp%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F04%2F23%2Fcomparison-remove-duplicate-chars-from-a-string-via-array-and-regexp%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/04/23/comparison-remove-duplicate-chars-from-a-string-via-array-and-regexp/&title=Comparison:+Remove+Duplicate+Chars+from+a+String+Via+Array+and+RegExp&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 the previous article, Remove Duplicate Chars from a String, I posted a way to remove duplicates characters from a string and make it of unique chars. So to make myself clear I&#8217;ll give the following example:</p>
<p>Source string: &#8220;<strong><u>aa</u>bbcc<u>aa</u>ddee</strong>&#8221;<br />
Should be: &#8220;<strong><u>a</u>bcde</strong>&#8221;<br />
<em>(note the underlined characters)</em>.</p>
<p>In my previous article TLP has commented and created a better method. You can see his comment <a href="http://www.flexer.info/2008/03/11/remove-duplicate-chars-from-a-string/#comment-176">here</a>.</p>
<p>His function is very straight forward, is based on the same concept, but is at least twice as faster. The steps are:</p>
<ol>
<li>split the string to an array</li>
<li>sort the array</li>
<li>join back to string</li>
<li>replace duplicates by only one character</li>
</ol>
<p>The code is:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> removeDuplicatesViaRegExp<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">string</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> 
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">string</span>.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>.<span style="color: #66cc66;">&#41;</span>\<span style="color: #cc66cc;">1</span>+<span style="color: #66cc66;">/</span>gi,<span style="color: #ff0000;">'$1'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>So I took both methods and built a new Flex application to test and compare them (see bellow).<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_removeduplicates_2079847931"
			class="flashmovie"
			width="300"
			height="557">
	<param name="movie" value="http://www.flexer.info/wp-content/uploads/2008/04/removeduplicates.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flexer.info/wp-content/uploads/2008/04/removeduplicates.swf"
			name="fm_removeduplicates_2079847931"
			width="300"
			height="557">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>I&#8217;m sure you&#8217;ll want the sources so at the end the source file can be downloaded.</p>
<p>For this new way, using regular expressions, to achieve the transformation to a string with unique characters, the credit goes to TLP. Thanks man. Great job.</p>
 <div class='series_links'><a href='http://www.flexer.info/2008/03/11/remove-duplicate-chars-from-a-string/' title='Remove Duplicate Chars from a String'>Previous in series</a> </div>]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/04/23/comparison-remove-duplicate-chars-from-a-string-via-array-and-regexp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Remove Duplicate Chars from a String</title>
		<link>http://www.flexer.info/2008/03/11/remove-duplicate-chars-from-a-string/</link>
		<comments>http://www.flexer.info/2008/03/11/remove-duplicate-chars-from-a-string/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 15:37:56 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Regexp]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.flexer.info/2008/03/11/remove-duplicate-chars-from-a-string/</guid>
		<description><![CDATA[This post is about how to remove duplicate characters from a string. And what I mean is that I want to make every char unique. 
Ex: &#8220;aabbbcccaadddee&#8221; will become &#8220;abcde&#8220;.
In &#8220;short words&#8221; the following steps are taken:

Split the string to an array (source array)
Create a second empty array which will retain the unique values
Sort the [...]]]></description>
			<content:encoded><![CDATA[<div class='series_toc'><h3>Table of contents<!-- for Remove Duplicate Chars --></h3><ol><li>Remove Duplicate Chars from a String</li><li><a href='http://www.flexer.info/2008/04/23/comparison-remove-duplicate-chars-from-a-string-via-array-and-regexp/' title='Comparison: Remove Duplicate Chars from a String Via Array and RegExp'>Comparison: Remove Duplicate Chars from a String Via Array and RegExp</a></li></ol></div> <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%2F03%2F11%2Fremove-duplicate-chars-from-a-string%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F03%2F11%2Fremove-duplicate-chars-from-a-string%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/03/11/remove-duplicate-chars-from-a-string/&title=Remove+Duplicate+Chars+from+a+String&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>This post is about how to remove duplicate characters from a string. And what I mean is that I want to make every char <strong>unique</strong>. </p>
<p>Ex: &#8220;<em><strong>aabbbcccaadddee</strong></em>&#8221; will become &#8220;<em><strong>abcde</strong></em>&#8220;.</p>
<p>In &#8220;short words&#8221; the following steps are taken:</p>
<ol>
<li>Split the string to an array (source array)</li>
<li>Create a second empty array which will retain the unique values</li>
<li>Sort the source array with case insensitive</li>
<li>Store current value for comparison
<li>Walk through the whole source array and for each character check if is the same with current value variable &#8211; if it is that character is not already added we add it to the second array (this because the source array is sorted and there cannot be an array like this after sorting:

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;a&quot;</span>,<span style="color: #ff0000;">&quot;b&quot;</span>,<span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p> but only sorted&#8230; like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;a&quot;</span>,<span style="color: #ff0000;">&quot;a&quot;</span>,<span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<li>Join back the second array to a string</li>
</ol>
<p>These are the steps and here is a function in Actionscript 3:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> removeDuplicates<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">string</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> 
<span style="color: #66cc66;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">var</span> arr:<span style="color: #0066CC;">Array</span> = <span style="color: #0066CC;">string</span>.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> currentValue:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>; 
    <span style="color: #000000; font-weight: bold;">var</span> tempArray:<span style="color: #0066CC;">Array</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: #66cc66;">&#41;</span>; 
    arr.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Array</span>.<span style="color: #006600;">CASEINSENSITIVE</span><span style="color: #66cc66;">&#41;</span>; 
    arr.<span style="color: #b1b100;">forEach</span><span style="color: #66cc66;">&#40;</span> 
        <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>item:<span style="color: #66cc66;">*</span>,<span style="color: #0066CC;">index</span>:uint,<span style="color: #0066CC;">array</span>:<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>currentValue <span style="color: #66cc66;">!</span>= item<span style="color: #66cc66;">&#41;</span> 
            <span style="color: #66cc66;">&#123;</span> 
                tempArray.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>item<span style="color: #66cc66;">&#41;</span>; 
                currentValue = item; 
            <span style="color: #66cc66;">&#125;</span> 
        <span style="color: #66cc66;">&#125;</span> 
    <span style="color: #66cc66;">&#41;</span>; 
    <span style="color: #b1b100;">return</span> tempArray.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Array</span>.<span style="color: #006600;">CASEINSENSITIVE</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I tried to have the same result using regular expressions but no success. And I stress that I meant about removing duplicates and making a unique chars string. Removing only duplicates is easy and I can put a regular expression here for that but that is not the purpose of this article. </p>
<p>If anyone resolved this using RegExp please share <img src='http://www.flexer.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
 <div class='series_links'> <a href='http://www.flexer.info/2008/04/23/comparison-remove-duplicate-chars-from-a-string-via-array-and-regexp/' title='Comparison: Remove Duplicate Chars from a String Via Array and RegExp'>Next in series</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/03/11/remove-duplicate-chars-from-a-string/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

