<?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>Anna Filina &#187; movieclips</title>
	<atom:link href="http://annafilina.com/blog/tag/movieclips/feed/" rel="self" type="application/rss+xml" />
	<link>http://annafilina.com/blog</link>
	<description>I fix stuff</description>
	<lastBuildDate>Thu, 17 May 2012 19:58:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex: working with MovieClips</title>
		<link>http://annafilina.com/blog/flex-working-with-movieclips/</link>
		<comments>http://annafilina.com/blog/flex-working-with-movieclips/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 20:48:33 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[movieclips]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/archives/35</guid>
		<description><![CDATA[You do not do everything with Flex components, especially if you develop games or cool interfaces. You often need to load SWF files and use the MovieClips inside them. A previous article talks about Instantiating and displaying MovieClips from loaded SWF.
Here are a few considerations when loading MovieClips into Flex:

If you embed a symbol, you<div><a href="http://annafilina.com/blog/flex-working-with-movieclips/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>You do not do everything with Flex components, especially if you develop games or cool interfaces. You often need to load SWF files and use the MovieClips inside them. A previous article talks about <a href="http://annafilina.com/blog/archives/27">Instantiating and displaying MovieClips from loaded SWF</a>.</p>
<p>Here are a few considerations when loading MovieClips into Flex:</p>
<ul>
<li>If you embed a symbol, you will lose all timeline actions. Embed the whole SWF instead.</li>
<p> </p>
<li>If you have a stop on the first frame of a multi-frame MovieClip, it might never execute. Add the action on the second frame.</li>
<p> </p>
<li>When you say gotoAndStop (or gotoAndPlay), you cannot immediately reference the children on that frame. You have 3 choices:
<ul>  </p>
<li>Use stage.invalidate() and listen to RENDER events</li>
<p> </p>
<li>Listen to ADDED events and check if the target of the event is the object that you need.</li>
<p> </p>
<li>Forget about frames and do like Flex intended: one symbol per MovieClip state (button states for example)</li>
<p> </ul>
</li>
<p> </p>
<li>If your MovieClip is 1-frame long, it will still loop indefinitely, consuming precious resources. Use stop() on the first frame.</li>
<p> </p>
<li>When you use the addChild method with the MovieClip, the clip will not be copied. It will be removed from its previous parent (firing the REMOVED_FROM_STAGE event) and then added to the new parent.</li>
<p> </p>
<li>You cannot duplicate a MovieClip. If you want to be able to create multiple instances, link these MovieClips in you SWFlibrary and instantiate as many as you want.</li>
<p> </p>
<li>A MovieClip cannot be added directly to Flex containers. Add it as a child of a SWFLoader or an Image and add that control.</li>
<p> </p>
<li>The Loader class is a DisplayObject but has trouble resizing itself. You can always grab the loader.content as a MovieClip and add it where you need it.</li>
<p> </ul>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/flex-working-with-movieclips/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Instantiating and displaying MovieClips from loaded SWF</title>
		<link>http://annafilina.com/blog/instantiating-and-displaying-movieclips-from-loaded-swf/</link>
		<comments>http://annafilina.com/blog/instantiating-and-displaying-movieclips-from-loaded-swf/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 01:03:47 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[movieclips]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/archives/27</guid>
		<description><![CDATA[So you want to dynamically load a .swf, instantiate it and add to to a SWFLoader control.
First, loading the .swf:
var loader:Loader = new Loader();
loader.load(url);
Now, to get its classes, we need to listen for the loading completion:
loader.addEventListener(Event.INIT, callbackFunction);
Once done, the callbackFunction will get and instantiate a class:
var mcClass:Class =
loader.content.loaderInfo.applicationDomain
  .getDefinition("instanceName") as Class;
var mc:MovieClip = MovieClip(new<div><a href="http://annafilina.com/blog/instantiating-and-displaying-movieclips-from-loaded-swf/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>So you want to dynamically load a .swf, instantiate it and add to to a SWFLoader control.</p>
<p>First, loading the .swf:</p>
<pre class="brush:as3">var loader:Loader = new Loader();
loader.load(url);</pre>
<p>Now, to get its classes, we need to listen for the loading completion:</p>
<pre class="brush:as3">loader.addEventListener(Event.INIT, callbackFunction);</pre>
<p>Once done, the callbackFunction will get and instantiate a class:</span></p>
<pre class="brush:as3">var mcClass:Class =
loader.content.loaderInfo.applicationDomain
  .getDefinition("instanceName") as Class;
var mc:MovieClip = MovieClip(new mcClass());
</pre>
<p>Hurray! Now we can add it to some appropriate container:</p>
<pre class="brush:as3">someSwfLoader.addChild(mc);</pre>
<p>Now we want to scale it to fit the available space:</p>
<pre class="brush:as3">mc.scaleX = mc.scaleY = someSwfLoader.width / mc.width;</pre>
<p>(a more complex algorithm may be used)</p>
<p>A problem may arise if your clip content is not at 0,0 coordinates:</p>
<pre class="brush:as3">var bounds:Rectangle = mc.getBounds(Application.application.stage);
mc.x -= bounds.left * mc.scaleX;
mc.y -= bounds.top * mc.scaleX;</pre>
<p>(if you have an ActionScript project instead of Flex, you&#8217;ll need to access the stage by other means)</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/instantiating-and-displaying-movieclips-from-loaded-swf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

