<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
<rss version="2.0" xml:base="http://www.connectedpixel.com/blog">
<channel>
 <title>connectedpixel.com - ActionScript</title>
 <link>http://www.connectedpixel.com/blog/taxonomy/term/21/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>Callback filter functions in E4X</title>
 <link>http://www.connectedpixel.com/blog/e4x/callbackfilters</link>
 <description>&lt;p&gt;While porting some xpath-heavy AS2 code to AS3, I ran into problems.  E4X (new and improved xml support in AS3) seems to make xpath obsolete.  However, all the E4X query examples in the docs use hard-coded literals. I can&#039;t use literals because I don&#039;t know at code-time what the queries are going to be. My AS2 code creates xpath paths dynamically from variables.   What is the E4X equivalent?&lt;/p&gt;
&lt;p&gt;
After some initial confusion on my part, I now get it.  In retrospect, what&#039;s below seems obvious -- but that&#039;s the way it always is.&lt;/p&gt;
&lt;h4&gt;
Selecting a variable-named node type&lt;/h4&gt;
&lt;p&gt;
Let&#039;s work with this xml:
&lt;/p&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/25">AS3</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/24">Flex</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Mon, 07 Jul 2008 16:21:35 -0700</pubDate>
</item>
<item>
 <title>Detecting unwell xml</title>
 <link>http://www.connectedpixel.com/blog/debug/xml/wellformed</link>
 <description>&lt;p&gt;If an XML file is created manually or edited manually, it is easy to misspell a closing tag, misplace a greater than sign or forget a quote mark – it&#039;s easy to create non-well-formed xml.  Flash will not be able to read it and your application will fail.  Furthermore, it might load some of the data and operate in a mysterious, crippled fashion, and the cause of the problem will not be obvious.&lt;/p&gt;
</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/20">Flash</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/2">Debugging</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Wed, 02 Jul 2008 14:52:24 -0700</pubDate>
</item>
<item>
 <title>Preprocessor ASSERTS in ActionScript</title>
 <link>http://www.connectedpixel.com/blog/debug/asserts</link>
 <description>&lt;p&gt;Unlike most other computer languages, when ActionScript code fails, it fails silently.  If my code sends an undefined argument to a function, there is no crash, no alert message, nothing scary.&lt;/p&gt;
&lt;p&gt;Overall, this is a good thing.  If my live swf hits a bug, it might work just fine, no one is the wiser and life goes goes on blissfully unaware.&lt;/p&gt;
&lt;p&gt;This behavior has a downside, however.  The bug that is ignored now might cascade into a serious problem later -- in the next frame or in some code far away from the source of the problem.  And I&#039;m left scratching my head trying to figure out the original source of the problem in my code.  The appearance of the problem and the source of the problem may be far apart.&lt;/p&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/2">Debugging</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/7">Tools</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Wed, 02 Jul 2008 15:05:38 -0700</pubDate>
</item>
<item>
 <title>Array.sortOn does not work with MovieClips</title>
 <link>http://www.connectedpixel.com/blog/gotcha/sorton</link>
 <description>&lt;p&gt;This problem drove me crazy.  I&#039;d thought I&#039;d get it in the google-verse so anyone else who runs into it can benefit from my pain.&lt;/p&gt;
&lt;p&gt;Array.sortOn() does not seem to work when the array elements are objects derived from MovieClip. The following code demonstrates.&lt;/p&gt;
&lt;p&gt;Simple class.  &quot;zz&quot; property will be used to sort an array of these objects.&lt;/p&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/19">Gotchas</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Thu, 24 Jul 2008 05:48:27 -0700</pubDate>
</item>
<item>
 <title>Face Morph - Part 1, Morphin&#039; George</title>
 <link>http://www.connectedpixel.com/blog/morph/animmorph</link>
 <description>&lt;p&gt;Unlike Grant Skinner&#039;s &lt;a 
href=&quot;http://www.gskinner.com/blog/archives/2005/10/flash_8_gooify.html&quot; target=&quot;_blank&quot; 
&gt;gooify&lt;/a&gt;, which is a free-form distortion, the morph presented here is more constrained.  
It has an editable triangle mesh (which I&#039;m not showing right now).&lt;/p&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/20">Flash</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/4">Graphics</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Thu, 10 Jul 2008 14:54:07 -0700</pubDate>
</item>
<item>
 <title>Simulate download: Static vars not re-initialized</title>
 <link>http://www.connectedpixel.com/blog/gotcha/ide/staticinit</link>
 <description>&lt;p&gt;The &#039;Simulate Download&#039; feature in the Flash IDE is very useful.  It can help debug race conditions that are a cause of intermittent problems.  However, it can also lead you astray.&lt;/p&gt;
&lt;p&gt;
Problem: AS2 static variables are NOT reinitialized when you hit control-Enter the 2nd time to go into simulate-download mode.&lt;/p&gt;  
&lt;p&gt;If you&#039;d like to try it, here&#039;s a simple test class:&lt;/p&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/20">Flash</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/19">Gotchas</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:44:09 -0700</pubDate>
</item>
<item>
 <title>Flash Perlin Texture Components: Wood and Marble</title>
 <link>http://www.connectedpixel.com/blog/texture/components/woodmarble</link>
 <description>&lt;p&gt;A while back, I wrote about rendering &lt;a href = &quot;/blog/texture/wood&quot; &gt;Wood&lt;/a&gt; and &lt;a href=&quot;/blog/texture/marble&quot; &gt;Marble&lt;/a&gt; using Perlin noise.  But I&#039;ve found that these code bits are a pain to use.  You need to write code just to see them.  You can&#039;t work with them in the Flash IDE; i.e. they are inconvenient.&lt;/p&gt;
&lt;p&gt;Solution: package them in components with live preview.  That way you can see them, adjust their color visually, mask them, drop shadow them, etc.&lt;/p&gt;
</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/20">Flash</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/4">Graphics</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:44:46 -0700</pubDate>
</item>
<item>
 <title>Component Array Parameter Gotcha</title>
 <link>http://www.connectedpixel.com/blog/gotcha/component/arrayparam</link>
 <description>&lt;p&gt;So the other day, I was working on a component that has an inspectable set/get array property.  I could not get it work.  Although the default value for this array was not zero length and the parameter in the dialog box was not zero length, the set function was being called with a zero-length array at initialization.&lt;/p&gt;&lt;p&gt;This was an invalid situation and broke my app.&lt;/p&gt;
&lt;p&gt;Here&#039;s a simplified version of the code:&lt;/p&gt;
</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/2">Debugging</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/19">Gotchas</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:45:45 -0700</pubDate>
</item>
<item>
 <title>Flash8 Perlin Marble Texture</title>
 <link>http://www.connectedpixel.com/blog/texture/marble</link>
 <description>&lt;p&gt;Last week, I wrote an article about using Flash 8 Perlin noise to generate a &lt;a href=&quot;http://www.connectedpixel.com/blog/texture/wood&quot;&gt;wood texture&lt;/a&gt;.  Today, it&#039;s marble.&lt;/p&gt;
&lt;p&gt;According to this &lt;a href=&quot;http://freespace.virgin.net/hugo.elias/models/m_perlin.htm&quot; target=&quot;newwin&quot;&gt;link&lt;/a&gt;, the Perlin formula for marble is:&lt;/p&gt;
&lt;code class=&quot;mathEq&quot; &gt;texture = cosine( x + perlin(x,y,z) )&lt;/code&gt;
&lt;p&gt;Again, we don&#039;t want to do math on every pixel -- too slow.  So, how do we do this with the existing Flash 8 API?  First, let&#039;s pretend that the perlin term in the above equation is not there.  Here&#039;s what our image would look like (this image is arbitrarily blue monochrome):&lt;br /&gt;&lt;/p&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/4">Graphics</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/8">Tutorials</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:46:51 -0700</pubDate>
</item>
<item>
 <title>Flash8 Perlin Wood Texture</title>
 <link>http://www.connectedpixel.com/blog/texture/wood</link>
 <description>&lt;p&gt;The Flash 8 documentation for perlinNoise() has this intriguing statement:&lt;/p&gt;  
&lt;blockquote style=&quot;font-style: normal&quot;&gt;&lt;p&gt;
You can use Perlin noise functions to simulate natural phenomena and landscapes, such as wood grain, clouds, and mountain ranges.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;OK. That sounds like fun.  But how is this done?  It&#039;s not immediately obvious, at least not to me.  So I googled .&lt;/p&gt;  
&lt;p&gt;
According to these links (&lt;a href=&quot;http://freespace.virgin.net/hugo.elias/models/m_perlin.htm&quot; target=&quot;newwin&quot; &gt;here&lt;/a&gt; and &lt;a href=&quot;http://www.soe.ucsc.edu/classes/cmps260/Spring02/submit/weishen/html/&quot; target=&quot;newwin&quot;&gt;here&lt;/a&gt;), the formula for wood is:&lt;/p&gt;
&lt;code class=&quot;mathEq&quot; &gt;g = perlin(x,y) * 20;&lt;br /&gt;
grain = g - int(g);&lt;/code&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/20">Flash</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/4">Graphics</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/8">Tutorials</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:47:10 -0700</pubDate>
</item>
<item>
 <title>Chicago MMUG Presentation tonight: Flash Components</title>
 <link>http://www.connectedpixel.com/blog/tutorial/chicagommug/10172005</link>
 <description>&lt;p&gt;Tonight (Oct 17), downtown Chicago, we&#039;re having a &lt;a href=&quot;http://www.mmugchicago.org/&quot; target=&quot;newwin&quot; &gt;Flash-component tutorial party&lt;/a&gt;.  We will learn:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to use them&lt;/li&gt;
&lt;li&gt;Where to get them&lt;/li&gt;
&lt;li&gt;Why they&#039;re so great&lt;/li&gt;
&lt;li&gt;And even (gasp!) how to make them (!!!)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As a special bonus, there will be gratuitous drop-shadows and blends so we can make a big deal about using Flash 8.&lt;/p&gt;
&lt;p&gt;If you left Chicago to go to MAX, you made a mistake (yes you, &lt;a href=&quot;http://www.oxygenbox.com&quot; target=&quot;newwin&quot;&gt;Michael Schaffner&lt;/a&gt;).  Quick, get on the plane and get back here!&lt;/p&gt;
</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/8">Tutorials</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Tue, 06 Jun 2006 19:44:13 -0700</pubDate>
</item>
<item>
 <title>AS2: Static vs. Instance vs. Setter Funcs</title>
 <link>http://www.connectedpixel.com/blog/performance/impact/functypes</link>
 <description>&lt;p&gt;Flash has several ways to define a function:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Class methods&lt;/li&gt;
&lt;li&gt;Setter/getter methods&lt;/li&gt;
&lt;li&gt;Static class methods&lt;/li&gt;
&lt;li&gt;Local functions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I wrote equivalent functions in each form and compared their performance.  The raw data is down below in the appendix.  I&#039;ll go over the results here that I find surprising:&lt;/p&gt;

&lt;div class=&quot;subentry&quot;&gt;
&lt;h3&gt;Setter/Getters vs. Regular Instance Functions&lt;/h3&gt;
&lt;pre&gt;
// Setter/Getter
p.XVal = 23.4;        // 25 msec / 1000
x = p.XVal;           // 12 msec / 1000
&lt;/pre&gt;
&lt;p align=&quot;center&quot;&gt;vs.&lt;/p&gt;&lt;/pre&gt;&lt;/div&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/6">Performance</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:48:43 -0700</pubDate>
</item>
<item>
 <title>AS2: Performance Impact of OO Coding Style</title>
 <link>http://www.connectedpixel.com/blog/performance/impact/oo</link>
 <description>&lt;p&gt;While writing that animated sine-wave thingy at the top of my web site, I ran into a problem -- my frame rate was terrible.  I was getting maybe 3 or 4 frames a second.  My browser was bogging down, my computer was bogging down.  I had to either speed it up, or I had to dump it.&lt;/p&gt;
&lt;p&gt;As it has many trig calculations in each frame, I thought that Math.sin() was to blame.  I was getting ready to write a table-lookup algorithm to replace Math.sin, when the little angel on my shoulder told me to quit guessing and be more scientific about it.  So I wrote a test program instead. I found that Math.sin was extremely fast and certainly not the cause of my problem.&lt;/p&gt;</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/6">Performance</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:49:06 -0700</pubDate>
</item>
<item>
 <title>Spirographs in Flash</title>
 <link>http://www.connectedpixel.com/blog/flashexp/graph/lissajou/1</link>
 <description>&lt;p&gt;Do you remember playing with a Spirograph when you were a kid?  Did you ever go to one of those rock-music laser shows at the planetarium?  (I think they went out of style in the mid 80&#039;s.)  Those complicated-looking patterns can be described mathematically as parametric equations where x and y are sinusoidal functions of a parameter t.&lt;/p&gt;
</description>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/20">Flash</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/17">Math</category>
 <category domain="http://www.connectedpixel.com/blog/taxonomy/term/21">ActionScript</category>
 <pubDate>Fri, 11 Apr 2008 18:49:58 -0700</pubDate>
</item>
</channel>
</rss>
