<?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>cs3 &#8211; Software, Fitness, and Gaming &#8211; Jesse Warden</title>
	<atom:link href="https://jessewarden.com/tag/cs3/feed" rel="self" type="application/rss+xml" />
	<link>https://jessewarden.com</link>
	<description>Software &#124; Fitness &#124; Gaming</description>
	<lastBuildDate>Tue, 28 Dec 2010 19:02:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://jessewarden.com/wp-content/uploads/2016/08/cropped-Lambda2-32x32.png</url>
	<title>cs3 &#8211; Software, Fitness, and Gaming &#8211; Jesse Warden</title>
	<link>https://jessewarden.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>JSFL Script to Ensure Actual ActionScript Classes Exist for Symbols</title>
		<link>https://jessewarden.com/2010/12/jsfl-script-to-ensure-actual-actionscript-classes-exist-for-symbols.html</link>
					<comments>https://jessewarden.com/2010/12/jsfl-script-to-ensure-actual-actionscript-classes-exist-for-symbols.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Tue, 28 Dec 2010 18:50:26 +0000</pubDate>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[cs3]]></category>
		<category><![CDATA[cs4]]></category>
		<category><![CDATA[cs5]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jsfl]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=2577</guid>

					<description><![CDATA[One way to design or skin ActionScript 3 projects is using the Flash IDE for graphical assets. Â You export your FLA as an SWC, and you can utilize those assets in your AS3 and/or Flex project. Â Flash CS3/CS4/CS5 have the ability to link to an ActionScript 3 class that represents the code behind the Symbol. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>One way to design or skin ActionScript 3 projects is using the <a href="http://adobe.com/products/flash/">Flash</a> IDE for graphical assets. Â You export your FLA as an SWC, and you can utilize those assets in your AS3 and/or Flex project. Â Flash CS3/CS4/CS5 have the ability to link to an ActionScript 3 class that represents the code behind the Symbol. Â If the Flash IDE doesn&#8217;t find the class in its source paths, it&#8217;ll create one for you.</p>
<p>The downside is, when you compile, you do not get errors if the Flash IDE didn&#8217;t find a class for a particular Symbol that&#8217;s set to have one. Â Maybe you mis-typed the package path or class name. Â Maybe you forgot to set the class path for the FLA. Â Maybe the FLA is in the wrong place. Â Whatever the reason, your code &#8220;won&#8217;t work&#8221; and you won&#8217;t know why. Â You may not get code hints in <a href="http://www.adobe.com/products/flashbuilder/">Flash Builder</a> / <a href="http://www.fdt.powerflasher.com/">FDT</a> / <a href="http://www.jetbrains.com/idea/">IntelliJ</a>, and certain other dependencies may be missing as well and you&#8217;ll be left wondering why.</p>
<p><span id="more-2577"></span><a href="http://jessewarden.com/archives/blogentryimages/check-class.jpg"><img decoding="async" style="padding-right: 4px; padding-bottom: 4px; width: 240px;" src="http://jessewarden.com/archives/blogentryimages/check-class.jpg" alt="Flash CS5 Check Class" width="240" align="left" /></a>The Flash IDE provides a check mark button next to the linkage class to allow you to confirm or deny Flash can find the class. Â In a quick scan of the <a href="http://help.adobe.com/en_US/flash/cs/extend/index.html">JavaScript for Flash docs</a>, I could not find a way to use this button&#8217;s functionality in JSFL. Â So, I wrote a quick script that does.</p>
<p><strong>NOTE</strong>: I do not take source paths into account; I assume that the classes are in the same directory as the FLA&#8217;s. Â You can easily change this by querying <a href="http://help.adobe.com/en_US/flash/cs/extend/WS5A00B146-30BC-4841-A27F-325968E8084B.html">fl.getDocumentDOM().sourcePath</a>, or just hardcoding your known path.</p>
<pre lang="Javascript">fl.outputPanel.clear();
fl.trace("*** Checking for un-found classes... ***");
var totalNotFound = 0;

var doc = fl.getDocumentDOM();
var lib = doc.library;
var items = lib.items;

var itemsLen = items.length;

for(var i = 0; i &lt; itemsLen; i++)
{

	var item = items[i];
	/*
	fl.trace("--------------");
	for(var prop in item)
	{
		fl.trace(prop + "::" + item[prop]);
	}
	*/

	if(item.linkageExportForAS)
	{
		var className = item.linkageClassName;
		var classPath = className.split(".").join("/");
		var exists = doesClassExistOnDisk(classPath);
		if(exists == false)
		{
			totalNotFound++;
			fl.trace("Couldn't find class for '" + item.name + "', class: " + className);
		}
	}

}

if(totalNotFound == 0)
{
	fl.trace("*** DONE. All classes found.");
}
else
{
	fl.trace("*** DONE. " + totalNotFound + " classes not found.");
}

function doesClassExistOnDisk(classPath)
{
	var filename = classPath + ".as";
	var doc = fl.getDocumentDOM();
	var currentFolder = doc.pathURI.split(doc.name).join("");
	var fullURI = currentFolder + filename;
	//fl.trace("fullURI: " + fullURI);
	return FLfile.exists(fullURI);
}</pre>
<p>On a side note, <a href="http://summitprojectsflashblog.wordpress.com/">Dru Kepple has a lot of wonderful JSFL classes</a> to help working with ActionScript in the Flash IDE, specifically <a href="http://summitprojectsflashblog.wordpress.com/2010/11/29/jsfl-get-notifications-on-a-bad-document-class/">the Document class.</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2010/12/jsfl-script-to-ensure-actual-actionscript-classes-exist-for-symbols.html/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How to Fix the Flash CS3 Components</title>
		<link>https://jessewarden.com/2008/03/how-to-fix-the-flash-cs3-components.html</link>
					<comments>https://jessewarden.com/2008/03/how-to-fix-the-flash-cs3-components.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Sat, 29 Mar 2008 00:32:54 +0000</pubDate>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[cs3]]></category>
		<category><![CDATA[Flex]]></category>
		<guid isPermaLink="false">http://jessewarden.com/2008/03/how-to-fix-the-flash-cs3-components.html</guid>

					<description><![CDATA[*** Update: This is NOT fixed in Flash CS4, nor in the 10.0.2 update. I guess Adobe is in denial that stage.invalidate() is broken, or they just don&#8217;t have the dough to throw at QA to get 3 lines of code + an updated set of SWC&#8217;s. *sigh* *** &#8230;and end the drawNow madness. I [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>*** <strong>Update:</strong> This is <strong>NOT</strong> fixed in Flash CS4, nor in the 10.0.2 update.  I guess Adobe is in denial that stage.invalidate() is broken, or they just don&#8217;t have the dough to throw at QA to get 3 lines of code + an updated set of SWC&#8217;s. *sigh* ***</p>
<p>&#8230;and end the drawNow madness.</p>
<p>I knew something was SERIOUSLY wrong when I read in the <a href="http://www.adobe.com/devnet/flash/articles/creating_as3_components.html">official docs (Part 3)</a> from Adobe that if your code doesn&#8217;t work correctly, try using &#8220;drawNow&#8221;, and failing that, &#8220;validateNow&#8221;.  What do you mean &#8220;try&#8221;?  What&#8230; the&#8230; hell&#8230;</p>
<p><span id="more-1263"></span>I was further curious when I dug in the source code.  The <a href="http://adobe.com/products/flex/">Flex</a> 2 &amp; 3 components do not have this problem, why <a href="http://adobe.com/products/flash/">Flash</a>?  It turned out to be a <a href="http://www.betriebsraum.de/blog/2007/11/03/stageinvalidate-and-eventrender-for-ui-elements/">bug in the Flash Player</a>.  The old way of doing invalidation in the Flex 1.5/1 &amp; Flash 8/MX 2004/MX components was to utilize onEnterFrame.  If you don&#8217;t know what invalidation is, I&#8217;ve written about it <a href="http://docs.google.com/Doc?id=dfcjvsm5_180f5skrq">here</a> under &#8220;Provides Invalidation&#8221;.  In a nutshell, it allows a component to only redraw once per frame even if you set a property 1000 times.</p>
<p>Now that ActionScript 3 is supposed to be all pure, and have nothing to do with frames and what not, the new way to handle invalidation is to utilize stage.invalidate.  This method triggers the Event.RENDER event for all those who are listening.</p>
<p>Problem?  You cannot call stage.invalidate() WHILE executing code that was triggered from an Event.RENDER.</p>
<p>Invalidation is powerful in that you can have a Label component that is very efficient in only redrawing it&#8217;s text and style changes once per frame.  In turn, that Label component is then put into a Button component who does his own invalidation.  When he sets the text, or sizes the Label, you can be sure that it&#8217;s ok if his methods aren&#8217;t written very well, and he accidentally has a situation where the Label has it&#8217;s text set more than once per frame, or perhaps he sizes it twice.  This process repeats itself as more and more complicated components are built using other components via <a href="http://en.wikipedia.org/wiki/Object_composition">Composition</a>.</p>
<p>This nested invalidation, however, doesn&#8217;t work in the Flash CS3 components because of that very bug.  My guess is, the crew building them didn&#8217;t know about this bug, and started implementing a convention of calling drawNow when stuff didn&#8217;t work right.  When they added drawNow, it did, and thus they started to have confidence grow in using drawNow .  Since this is AS3, you don&#8217;t really notice the performance impact since you&#8217;re busy building components and testing really small use cases, not larger applications.  The drawNow method basically doesn&#8217;t wait a frame; it just draws right now.</p>
<p>Why doesn&#8217;t Flex have this problem?  It uses both; Event.RENDER, and you guessed it, Event.ENTER_FRAME.</p>
<p>If you&#8217;re a Flash Developer, it&#8217;s an easy fix.  You can replace the existing 2 functions in fl.core.UIComponent with the code below.  If you&#8217;re doing AS3 Projects utilizing mxmlc, whether Flex Builder or <a href="http://www.flashdevelop.org/community/">Flash Develop</a>, utilizing the Flash CS3 components because <a href="http://www.bit-101.com/blog/?p=1126">Keith Peter&#8217;s minimalist components</a> aren&#8217;t thorough enough for your needs&#8230; it gets a little trickier.  Basically, you do the same thing a Flash Developer would, re-export your SWC&#8217;s, and then re-link them into your libs folder of choice.</p>
<p>I haven&#8217;t figured out the best way to handle this in a multi-developer environment.  You can&#8217;t check fl.core.UIComponent into Subversion because if Flex Builder sees a fl class, it&#8217;ll use that instead of the SWC&#8217;s, thus breaking the Flash components you&#8217;ve imported.</p>
<p>Anyway, here&#8217;s what you do:</p>
<p>1. Take the following code, and replace the &#8220;callLater&#8221; and &#8220;callLaterDispatcher&#8221; methods.</p>
<pre><span class="linecomment">// HACK
</span><span class="linecomment">// Found here:
</span><span class="linecomment">// http://www.kirupa.com/forum/showthread.php?t=287632
</span><span class="linecomment">//
</span><span class="linecomment">// HACK
</span><span class="linecomment">// Added Event.ENTER_FRAME listener because of
</span><span class="linecomment">// stage.invalidate bug with Event.RENDER
</span><span class="linecomment">// http://jessewarden.com/2008/03/how-to-fix-the-flash-cs3-components.html</span>
protected <span class="keyword">function</span> callLater(fn:<span class="identifier">Function</span>):<span class="keyword">void</span> {
        callLaterMethods[fn] = <span class="identifier">true</span>;
        <span class="keyword">if</span> (stage != <span class="identifier">null</span>) {
                stage.<span class="identifier2">addEventListener</span>(Event.ENTER_FRAME,callLaterDispatcher,<span class="identifier">false</span>,0,<span class="identifier">true</span>);
                stage.<span class="identifier2">addEventListener</span>(Event.RENDER,callLaterDispatcher,<span class="identifier">false</span>,0,<span class="identifier">true</span>);
                stage.<span class="identifier2">invalidate</span>();
        } <span class="keyword">else</span> {
                <span class="identifier2">addEventListener</span>(Event.ADDED_TO_STAGE,callLaterDispatcher,<span class="identifier">false</span>,0,<span class="identifier">true</span>);
        }
}

<span class="keyword">private</span> <span class="keyword">function</span> callLaterDispatcher(<span class="identifier2">event</span>:Event):<span class="keyword">void</span> {
        <span class="keyword">if</span> (<span class="identifier2">event</span>.<span class="identifier">type</span> == Event.ADDED_TO_STAGE) {
                <span class="identifier2">removeEventListener</span>(Event.ADDED_TO_STAGE,callLaterDispatcher);
                stage.<span class="identifier2">addEventListener</span>(Event.ENTER_FRAME,callLaterDispatcher,<span class="identifier">false</span>,0,<span class="identifier">true</span>);
                <span class="linecomment">// now we can listen for render event:
</span>                stage.<span class="identifier2">addEventListener</span>(Event.RENDER,callLaterDispatcher,<span class="identifier">false</span>,0,<span class="identifier">true</span>);
                stage.<span class="identifier2">invalidate</span>();

                <span class="keyword">return</span>;
        } <span class="keyword">else</span> {
                <span class="identifier2">event</span>.<span class="identifier">target</span>.<span class="identifier2">removeEventListener</span>(Event.ENTER_FRAME,callLaterDispatcher);
                <span class="identifier2">event</span>.<span class="identifier">target</span>.<span class="identifier2">removeEventListener</span>(Event.RENDER,callLaterDispatcher);
                <span class="keyword">if</span> (stage == <span class="identifier">null</span>) {
                        <span class="linecomment">// received render, but the stage is not available, so we will listen for addedToStage again:
</span>                        <span class="identifier2">addEventListener</span>(Event.ADDED_TO_STAGE,callLaterDispatcher,<span class="identifier">false</span>,0,<span class="identifier">true</span>);
                        <span class="keyword">return</span>;
                }
        }
        <span class="keyword">var</span> methods:Dictionary = <span class="keyword">new</span> Dictionary();
        <span class="keyword">for</span> (<span class="keyword">var</span> copyMethod:<span class="identifier">Object</span> <span class="keyword">in</span> callLaterMethods) {
                methods[copyMethod] = callLaterMethods[copyMethod];
                <span class="keyword">delete</span>(callLaterMethods[copyMethod]);
        }
        <span class="keyword">for</span> (<span class="keyword">var</span> method:<span class="identifier">Object</span> <span class="keyword">in</span> methods) {
                method();
        }
}</pre>
<p>2. Save your file.</p>
<p>3. Reboot Flash.</p>
<p>4. In your FLA, delete the &#8220;ComponentShim&#8221; out of your Library.</p>
<p>5. Stop frikin&#8217; using drawNow.</p>
<p>Keep in mind, there still are other issues with the CS3 components this won&#8217;t fix.  Just because you implement <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/listClasses/ICellRenderer.html">ICellRenderer</a> doesn&#8217;t mean you&#8217;ll work in a <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/TileList.html">TileList</a>.  UILoader didn&#8217;t get <a href="http://www.kaourantin.net/2005/12/dynamically-loading-bitmaps-with.html">the memo</a>.  The rotated vertical Slider makes skinning a nightmare.  Transitions&#8230; don&#8217;t get me started.</p>
<p>On a less sarcastic note, there ARE valid uses of drawNow.  For example, you cannot do effective measurement of assets if they aren&#8217;t rendered.  Therefore, drawNow/validateNow have to be utilized to clear all dirty flags so you can get accurate measurements of width and height.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2008/03/how-to-fix-the-flash-cs3-components.html/feed</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
	</channel>
</rss>
