<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Create a pseudo-class from a runtime-loaded image in AS3</title>
	<atom:link href="http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Wed, 16 May 2012 17:12:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Don</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-35103</link>
		<dc:creator>Don</dc:creator>
		<pubDate>Mon, 05 Mar 2012 06:21:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-35103</guid>
		<description>Thanks Josh.  That works.</description>
		<content:encoded><![CDATA[<p>Thanks Josh.  That works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-35068</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Sun, 04 Mar 2012 23:23:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-35068</guid>
		<description>Don, you should probably wait until the image is loaded before you resize it.</description>
		<content:encoded><![CDATA[<p>Don, you should probably wait until the image is loaded before you resize it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-34976</link>
		<dc:creator>Don</dc:creator>
		<pubDate>Sun, 04 Mar 2012 08:26:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-34976</guid>
		<description>Hi Josh, how do I resize the loaded bitmap from your loader function?  I tried resize the image to half the size (see below), but nothing is displayed.  Thanks in advance.

&lt;pre&gt;//loaded image is 100x100, want to resize it to 50x50
var ImageType:Function = LoaderUtil.createAutoLoader(o.url);
var image1:Loader = new ImageType();
image1.width = 50;
image1.scaleY = image1.scaleX;
addChild(image1);&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi Josh, how do I resize the loaded bitmap from your loader function?  I tried resize the image to half the size (see below), but nothing is displayed.  Thanks in advance.</p>
<pre>//loaded image is 100x100, want to resize it to 50x50
var ImageType:Function = LoaderUtil.createAutoLoader(o.url);
var image1:Loader = new ImageType();
image1.width = 50;
image1.scaleY = image1.scaleX;
addChild(image1);</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-27066</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Tue, 03 Jan 2012 05:09:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-27066</guid>
		<description>Don, it returns a function that you can use with the &lt;code&gt;new&lt;/code&gt; keyword, like a class.

&lt;pre&gt;var ImageType:Function = LoaderUtil.createAutoLoader(o.url);
var image1:Loader = new ImageType();
addChild(image1);&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Don, it returns a function that you can use with the <code>new</code> keyword, like a class.</p>
<pre>var ImageType:Function = LoaderUtil.createAutoLoader(o.url);
var image1:Loader = new ImageType();
addChild(image1);</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-27040</link>
		<dc:creator>Don</dc:creator>
		<pubDate>Tue, 03 Jan 2012 03:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-27040</guid>
		<description>Hi Josh.
I&#039;m pretty new to AS3.  How do you use the &quot;createAutoLoader&quot; class function?  I did the following but getting error during execution.  Any help is appreciated.

var image1 = LoaderUtil.createAutoLoader(o.url);
addChild(image1);

TypeError: Error #1034: Type Coercion failed: cannot convert Function to flash.display.DisplayObject.</description>
		<content:encoded><![CDATA[<p>Hi Josh.<br />
I&#8217;m pretty new to AS3.  How do you use the &#8220;createAutoLoader&#8221; class function?  I did the following but getting error during execution.  Any help is appreciated.</p>
<p>var image1 = LoaderUtil.createAutoLoader(o.url);<br />
addChild(image1);</p>
<p>TypeError: Error #1034: Type Coercion failed: cannot convert Function to flash.display.DisplayObject.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Metal Hurlant</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1495</link>
		<dc:creator>Metal Hurlant</dc:creator>
		<pubDate>Wed, 21 Nov 2007 02:07:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1495</guid>
		<description>Prototype isn&#039;t strictly needed here. A function created within a function is a closure, so it keeps a snapshot of the outer functions&#039; locale variables in its scope.

The body of createAutoLoader() can simply be:

&lt;pre&gt;&lt;code&gt;return function():Loader {
    var loader:Loader = new Loader();
    loader.load(new URLRequest(url), context);
    return loader;
};&lt;/code&gt;&lt;/pre&gt;

One behavioral difference between this and an embedded asset is the dreaded one-frame minimum wait for the remotely loaded image, even when the image is already in the browser cache.
There are workarounds for it. Ely Greenfield has a &lt;a href=&quot;http://www.quietlyscheming.com/blog/2007/01/29/new-flex-componentsample-superimage/&quot; rel=&quot;nofollow&quot;&gt;Flex SuperImage component&lt;/a&gt; that gets the general idea right.
To deal with multiple loads of the same asset, you&#039;d want to cache the BitmapData object, and associates that with the url. Further attempts to instanciate the AutoLoader would just create a new Bitmap with that BitmapData.</description>
		<content:encoded><![CDATA[<p>Prototype isn&#8217;t strictly needed here. A function created within a function is a closure, so it keeps a snapshot of the outer functions&#8217; locale variables in its scope.</p>
<p>The body of createAutoLoader() can simply be:</p>
<pre><code>return function():Loader {
    var loader:Loader = new Loader();
    loader.load(new URLRequest(url), context);
    return loader;
};</code></pre>
<p>One behavioral difference between this and an embedded asset is the dreaded one-frame minimum wait for the remotely loaded image, even when the image is already in the browser cache.<br />
There are workarounds for it. Ely Greenfield has a <a href="http://www.quietlyscheming.com/blog/2007/01/29/new-flex-componentsample-superimage/" rel="nofollow">Flex SuperImage component</a> that gets the general idea right.<br />
To deal with multiple loads of the same asset, you&#8217;d want to cache the BitmapData object, and associates that with the url. Further attempts to instanciate the AutoLoader would just create a new Bitmap with that BitmapData.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1494</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Mon, 29 Oct 2007 19:38:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1494</guid>
		<description>There&#039;s another solution, but it&#039;s really hacky.  You can create a stand-alone SWF that has your MyImageClass as a symbol in it (make sure to save the swf as uncompressed) and load it into your SWF as a bytearray.  Save a copy of this bytearray once it&#039;s loaded.

When you need to create a new class, make a copy of the bytearray and patch the data in the bytearray containing the string to the string you&#039;re interested in.  This clearly will require some hacking around with the SWF file format to make this work.  Finally, load from the bytearray and use getDefinition to get the class object.

This is clearly way overkill for the case at hand, though.  But it does illuminate thte possibility of generating classes at run-time.  It&#039;s just very, very difficult.

Too bad actionscript doesn&#039;t have eval().  :)</description>
		<content:encoded><![CDATA[<p>There&#8217;s another solution, but it&#8217;s really hacky.  You can create a stand-alone SWF that has your MyImageClass as a symbol in it (make sure to save the swf as uncompressed) and load it into your SWF as a bytearray.  Save a copy of this bytearray once it&#8217;s loaded.</p>
<p>When you need to create a new class, make a copy of the bytearray and patch the data in the bytearray containing the string to the string you&#8217;re interested in.  This clearly will require some hacking around with the SWF file format to make this work.  Finally, load from the bytearray and use getDefinition to get the class object.</p>
<p>This is clearly way overkill for the case at hand, though.  But it does illuminate thte possibility of generating classes at run-time.  It&#8217;s just very, very difficult.</p>
<p>Too bad actionscript doesn&#8217;t have eval().  <img src='http://joshblog.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1493</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Mon, 22 Oct 2007 15:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1493</guid>
		<description>Ian, I have not found a better solution.</description>
		<content:encoded><![CDATA[<p>Ian, I have not found a better solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Thomas</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1492</link>
		<dc:creator>Ian Thomas</dc:creator>
		<pubDate>Mon, 22 Oct 2007 15:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1492</guid>
		<description>Hi Josh,
  Sounds like I&#039;m currently jumping through exactly the same hoops as you; having real trouble generating a Class object uniquely tied to a BitmapAsset with some associated bitmap Data (I&#039;m trying to do something like you describe with the Flex .icon property).

It&#039;s maddening. Did you get any further than you describe here?

Ian</description>
		<content:encoded><![CDATA[<p>Hi Josh,<br />
  Sounds like I&#8217;m currently jumping through exactly the same hoops as you; having real trouble generating a Class object uniquely tied to a BitmapAsset with some associated bitmap Data (I&#8217;m trying to do something like you describe with the Flex .icon property).</p>
<p>It&#8217;s maddening. Did you get any further than you describe here?</p>
<p>Ian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1491</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Thu, 04 Oct 2007 06:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeuslabs.us/2007/09/28/actionscript-3-bitmap-image-classes-with-functions-and-loaders/#comment-1491</guid>
		<description>TorbjÃ¸rn, I wouldn&#039;t be golden with your suggested method. What if I have two images to load? The static var only supports a single image unless I take special care in timing when the class may be used. I&#039;ll need to change the URL to load the second image, but what if the component needs to use the first URL again? It will have been lost.

Trust me, I tried &lt;em&gt;many&lt;/em&gt; possible approaches over a period of a few days, including what you&#039;ve suggested.</description>
		<content:encoded><![CDATA[<p>TorbjÃ¸rn, I wouldn&#8217;t be golden with your suggested method. What if I have two images to load? The static var only supports a single image unless I take special care in timing when the class may be used. I&#8217;ll need to change the URL to load the second image, but what if the component needs to use the first URL again? It will have been lost.</p>
<p>Trust me, I tried <em>many</em> possible approaches over a period of a few days, including what you&#8217;ve suggested.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

