<?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>Robertdot, A Web Design Blog &#187; Flash</title>
	<atom:link href="http://robertdot.org/tags/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://robertdot.org</link>
	<description>A web design blog for designers that develop or developers that design.</description>
	<lastBuildDate>Tue, 25 Jan 2011 20:43:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting Around Onload in Flash</title>
		<link>http://robertdot.org/2010/03/05/getting-around-onload-in-flash/</link>
		<comments>http://robertdot.org/2010/03/05/getting-around-onload-in-flash/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 15:59:57 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://robertdot.org/?p=194</guid>
		<description><![CDATA[I&#8217;ve been doing some Flash work recently and ran into a conundrum.  You can&#8217;t create an empty movie clip, load a movie in it, and do a movie.onload=function(){...}.  There are lots of work arounds, but here&#8217;s the one I just came up with that I liked.

function loadMyMovie&#40;clipName, depth, loadInClip, funcbefore, funcafter&#41; &#123;
	var watchLoad [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some Flash work recently and ran into a conundrum.  You can&#8217;t create an empty movie clip, load a movie in it, and do a <code>movie.onload=function(){...}</code>.  There are lots of work arounds, but here&#8217;s the one I just came up with that I liked.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> loadMyMovie<span style="color: #66cc66;">&#40;</span>clipName, depth, loadInClip, funcbefore, funcafter<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> watchLoad = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span>clipName<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">getBytesLoaded</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span>clipName<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">getBytesTotal</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span>clipName<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">getBytesTotal</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			funcafter.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
			setTimeout<span style="color: #66cc66;">&#40;</span>watchLoad,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>;
	<span style="color: #0066CC;">_root</span>.<span style="color: #0066CC;">createEmptyMovieClip</span><span style="color: #66cc66;">&#40;</span>clipName, depth<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span>clipName<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">loadMovie</span><span style="color: #66cc66;">&#40;</span>loadInClip<span style="color: #66cc66;">&#41;</span>;
	funcbefore.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	watchLoad<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><code>funcbefore</code> and <code>funcafter</code> should be the functions that show and hide your loading message.</p>
<p>I haven&#8217;t tested this exact bit of code, but that&#8217;s the basic principle.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2010/03/05/getting-around-onload-in-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

