<?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>Jozef Chúťka&#039;s blog &#187; library</title>
	<atom:link href="http://blog.yoz.sk/tag/library/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yoz.sk</link>
	<description>My life, my work</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:40:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Embedding assets wisely</title>
		<link>http://blog.yoz.sk/2009/10/embedding-assets-wisely/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=embedding-assets-wisely</link>
		<comments>http://blog.yoz.sk/2009/10/embedding-assets-wisely/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 08:16:07 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[asset]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[SpriteAsset]]></category>
		<category><![CDATA[symbol]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=302</guid>
		<description><![CDATA[You can embed various types of assets in your Adobe Flex applications (.jpeg, .png, .swf, .mp3, .svg, .ttf &#8230;). Embedded assets are compiled into the SWF file of your Flex application. They are not loaded at run time and you do not have to deploy the original asset files with your application. Read more about [...]]]></description>
			<content:encoded><![CDATA[<p>You can embed various types of assets in your Adobe Flex applications (.jpeg, .png, .swf, .mp3, .svg, .ttf &#8230;). Embedded assets are compiled into the SWF file of your Flex application. They are not loaded at run time and you do not have to deploy the original asset files with your application. Read more about embedding assets <a href="http://www.adobe.com/devnet/flex/quickstart/embedding_assets/">on Adobe</a>.</p>
<p>Basics first. How to make your symbol from Flash library visible for Flex (see images on the bottom of the artice):</p>
<ul>
<li>1. Create your symbol and linkage (library (Ctrl+L) / {your symbol} / Linkage&#8230;).</li>
<li>2. Linkage Properties, set your class name that will be used in [Embed] meta.</li>
<li>3. Export .swf file and make Assets.as.</li>
</ul>
<p><span id="more-302"></span></p>
<p>It is very handy to use central assets class. This is how I make my assets accessible in Flex application:</p>
<pre class="brush: as3; title: ; notranslate">package
{
    import mx.core.SpriteAsset;

    public class Assets extends Object
    {
        // change/to/your/uber/cool/path/and/filename.whatsoever
        // you can also embed graphic files (.jpeg, .png, )
        [Embed(source=&quot;../libs/assets.swf#symbol1&quot;)]
        public static const symbol1Class:Class;
        public static const symbol1SpriteAsset:SpriteAsset = new symbol1Class();

        [Embed(source=&quot;../libs/assets.swf&quot;, symbol=&quot;symbol2&quot;)]
        public static const symbol2Class:Class;

        // embedding Bitmap
        [Embed(source=&quot;../libs/image.png&quot;)]
        public static const imageClass:Class;
        public static const imageBitmap:Bitmap = new imageClass();

        public function Assets()
        {
            super();
        }
    }
}</pre>
<p>There are two ways how to ask for your symbol from .swf library &#8211; <em>1. source=&#8221;&#8230;#symbol1&#8243;</em> or <em>2. source=&#8221;&#8230;&#8221; symbol=&#8221;symbol2&#8243;</em>. Symbol name is whatever you set in Linkage Properties Class in Flash (not symbol name in library!).</p>
<p>Usage example:</p>
<pre class="brush: as3; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;horizontal&quot; applicationComplete=&quot;init()&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import Assets;

    private function init():void
    {
        container1.setStyle(&quot;backgroundImage&quot;, Assets.symbol1Class);
        container2.setStyle(&quot;backgroundImage&quot;, Assets.symbol2Class);
        container3.addChild(Assets.symbol1SpriteAsset);
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Box id=&quot;container1&quot; width=&quot;100&quot; height=&quot;100&quot;/&gt;
&lt;mx:Box id=&quot;container2&quot; width=&quot;100&quot; height=&quot;100&quot;/&gt;
&lt;mx:UIComponent id=&quot;container3&quot; width=&quot;100&quot; height=&quot;100&quot;/&gt;
&lt;/mx:Application&gt;</pre>
<p>Embedding proccess and example result in images:</p>
<p><div id="attachment_305" class="wp-caption alignnone" style="width: 210px"><a href="http://blog.yoz.sk/wp-content/uploads/how_to_linkage_symbol.png"><img src="http://blog.yoz.sk/wp-content/uploads/how_to_linkage_symbol-200x157.png" alt="Flash linkage symbol" title="how_to_linkage_symbol" width="200" height="157" class="size-medium wp-image-305" /></a><p class="wp-caption-text">Flash linkage symbol</p></div><br />
<div id="attachment_306" class="wp-caption alignnone" style="width: 210px"><a href="http://blog.yoz.sk/wp-content/uploads/linkage_properties.png"><img src="http://blog.yoz.sk/wp-content/uploads/linkage_properties-200x158.png" alt="Flash linkage properties" title="linkage_properties" width="200" height="158" class="size-medium wp-image-306" /></a><p class="wp-caption-text">Flash linkage properties</p></div><br />
<div id="attachment_307" class="wp-caption alignnone" style="width: 210px"><a href="http://blog.yoz.sk/wp-content/uploads/embeded.png"><img src="http://blog.yoz.sk/wp-content/uploads/embeded-200x125.png" alt="Flex embedded symbols" title="embeded" width="200" height="125" class="size-medium wp-image-307" /></a><p class="wp-caption-text">Flex embedded symbols</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/embedding-assets-wisely/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

