<?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>symbol &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/symbol/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Flex 3 import swf symbols</title>
		<link>/2009/03/05/flex-3-import-swf-symbols/</link>
		<comments>/2009/03/05/flex-3-import-swf-symbols/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 07:30:35 +0000</pubDate>
		<dc:creator><![CDATA[stoimen]]></dc:creator>
				<category><![CDATA[featured]]></category>
		<category><![CDATA[flex 3]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[movie clip]]></category>
		<category><![CDATA[symbol]]></category>

		<guid isPermaLink="false">/?p=291</guid>
		<description><![CDATA[Embedding a .swf file into Flex application can be difficult sometimes. Learn how to solve this issue.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/03/01/flex-3-custom-datechooser-2/" rel="bookmark" title="Flex 3 Custom DateChooser">Flex 3 Custom DateChooser </a></li>
<li><a href="/2009/03/18/flex-3-text-editor/" rel="bookmark" title="Flex 3 text editor">Flex 3 text editor </a></li>
<li><a href="/2009/03/15/flex-3-bitmap-with-round-corners/" rel="bookmark" title="Flex 3 bitmap with round corners">Flex 3 bitmap with round corners </a></li>
<li><a href="/2009/02/06/flex-3-custom-preloader/" rel="bookmark" title="Flex 3 Custom Preloader">Flex 3 Custom Preloader </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;d like to embed a .swf file into your Flex 3 application you&#8217;ll probably get into several little problems. The simple task of embedding is clear and well documented in the web. Let&#8217;s assume we&#8217;ve to MovieClip symbols into a single .swf file. What we like to do is to access this two separate symbols within the Flex applications as MovieClip.</p>
<figure id="attachment_292" style="width: 300px" class="wp-caption alignnone"><a href="/wp-content/uploads/2009/03/embed_swf_symbols_1.png"><img class="size-medium wp-image-292" title="embed_swf_symbols_1" src="/wp-content/uploads/2009/03/embed_swf_symbols_1-300x247.png" alt="make a movie clip in your flash" width="300" height="247" srcset="/wp-content/uploads/2009/03/embed_swf_symbols_1-300x247.png 300w, /wp-content/uploads/2009/03/embed_swf_symbols_1.png 796w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption class="wp-caption-text">Make a new MovieClip symbol in your Flash</figcaption></figure>
<p>Make the .swf sample file with both symbols inside. In general it&#8217;s not that hard, just put this into your Flex application code:</p>
<p><code>[Embed(source="embed.swf", symbol="blue")]<br />
private var blue:Class;</code></p>
<p>[Embed(source=&#8221;embed.swf, symbol=&#8221;red&#8221;)]<br />
private var red:Class</p>
<p>Note that you&#8217;ve embed.swf file, which has to be in the same folder as the main .swf of the Flex app, and two symbols named red and blue for the sample. Be very careful when exporting the symbols from the .swf file. Do not forget to export them for actionscript.</p>
<figure id="attachment_293" style="width: 295px" class="wp-caption alignnone"><a href="/wp-content/uploads/2009/03/embed_swf_symbols_2.png"><img class="size-medium wp-image-293" title="embed_swf_symbols_2" src="/wp-content/uploads/2009/03/embed_swf_symbols_2-295x300.png" alt="Don't forget to export the .swf MovieClip for actionscript" width="295" height="300" srcset="/wp-content/uploads/2009/03/embed_swf_symbols_2-295x300.png 295w, /wp-content/uploads/2009/03/embed_swf_symbols_2.png 676w" sizes="(max-width: 295px) 100vw, 295px" /></a><figcaption class="wp-caption-text">Don&#39;t forget to export the .swf MovieClip for actionscript</figcaption></figure>
<p>If not exported like that, you&#8217;ll have trouble accessing them from the Flex app, and that&#8217;s the first problem you can have here.</p>
<figure id="attachment_294" style="width: 300px" class="wp-caption alignnone"><a href="/wp-content/uploads/2009/03/embed_swf_symbols_3.png"><img class="size-medium wp-image-294" title="embed_swf_symbols_3" src="/wp-content/uploads/2009/03/embed_swf_symbols_3-300x212.png" alt="Set the name of the MovieClip exactly as you wish to appear in your Flex application" width="300" height="212" srcset="/wp-content/uploads/2009/03/embed_swf_symbols_3-300x212.png 300w, /wp-content/uploads/2009/03/embed_swf_symbols_3.png 577w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption class="wp-caption-text">Set the name of the MovieClip exactly as you wish to appear in your Flex application</figcaption></figure>
<p>The rest you have to do is to add this two lines of code in Flex:</p>
<p><code>var mc:MovieClip = new blue();<br />
this.addChild(mc);</code></p>
<p>Note that the last line can have something else than &#8216;this&#8217; if there&#8217;s other element to become parent of the imported MovieClip symbol. Here comes the first major problem. As <a title="www.airtightinteractive.com" href="http://www.airtightinteractive.com/news/?p=112" target="_blank">www.airtightinteractive.com</a> describes this technique does not work every time:</p>
<blockquote><p><em>Sometimes when you do this you will get the following error: </em></p>
<p><em><strong>TypeError: Error #1034: Type Coercion failed: cannot convert app_red@12510d1 to flash.display.MovieClip.</strong></em></p></blockquote>
<p>And the author shares his solution which is to add at least 2 keyframes for both movie clips, so that they can be visible as movie clips, if not they will remain visible only as Sprites.</p>
<p>I&#8217;m not as conviced this is the right answer of the question and the right solution. I&#8217;ve experimented with 1 or 2 keyframes and still have the same problem in Flex even if i cast the symbols as Sprite, not MovieClip:</p>
<p><code><span style="text-decoration: line-through;">var mc:MovieClip = new blue();</span><br />
var mc:Sprite = new blue();</code></p>
<p>The solution from Adobes for me is not suficient, cause the movie clips we import (embed) does not serve as images but more like movie clips, which was the task from the beggining. And that&#8217;s what <a title="adobe" href="http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html" target="_blank">Adobe</a> says:</p>
<blockquote><p><em>Flex fully supports embedding Flash SWF files. You can embed different types of SWF files.</em><br />
<em>&#8230;</em><br />
<em>To reference a symbol, you specify the symbol parameter:</em><br />
<em>[Embed(source=&#8217;SWFFileName.swf&#8217;, symbol=&#8217;symbolName&#8217;)]</em></p></blockquote>
<p>And again read carefully the note in the Adobe&#8217;s site:</p>
<blockquote><p><em><strong>Note</strong>: Flash defines three types of<br />
symbols: Button, MovieClip, and Graphic. You can embed Button and<br />
MovieClip symbols in a Flex application, but you cannot embed a Graphic symbol because it cannot be exported for ActionScript.</em></p></blockquote>
<p>Here you can be sure that lack of exported for actionscript symbol is not accessible in Flex.</p>
<p>One of the main solutions is to embed the .swf as octet-stream:</p>
<p><code>[Embed(source="embed.swf", mimeType="application/octet-stream")]<br />
private var blue:Class;</code></p>
<p>followed by:</p>
<p><code>var loader:Loader = new Loader()<br />
loader.loadBytes(new blue());</code></p>
<p>And the key point of this will be the lines:</p>
<p><code>var red:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("blue");<br />
var mc:MovieClip = new red() as MovieClip;</code></p>
<p>I hope this can help</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/03/01/flex-3-custom-datechooser-2/" rel="bookmark" title="Flex 3 Custom DateChooser">Flex 3 Custom DateChooser </a></li>
<li><a href="/2009/03/18/flex-3-text-editor/" rel="bookmark" title="Flex 3 text editor">Flex 3 text editor </a></li>
<li><a href="/2009/03/15/flex-3-bitmap-with-round-corners/" rel="bookmark" title="Flex 3 bitmap with round corners">Flex 3 bitmap with round corners </a></li>
<li><a href="/2009/02/06/flex-3-custom-preloader/" rel="bookmark" title="Flex 3 Custom Preloader">Flex 3 Custom Preloader </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/03/05/flex-3-import-swf-symbols/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
