<?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>danrichardson.net &#187; flash</title>
	<atom:link href="http://danrichardson.net/blog/tag/flash/feed" rel="self" type="application/rss+xml" />
	<link>http://danrichardson.net/blog</link>
	<description>tech / health / fitness blog</description>
	<lastBuildDate>Thu, 01 Jul 2010 09:06:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dynamic getURL in flash</title>
		<link>http://danrichardson.net/blog/tech/2008/07/29/dynamic-geturl-in-flash</link>
		<comments>http://danrichardson.net/blog/tech/2008/07/29/dynamic-geturl-in-flash#comments</comments>
		<pubDate>Tue, 29 Jul 2008 14:24:52 +0000</pubDate>
		<dc:creator>reason</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://danrichardson.net/wp/?p=18</guid>
		<description><![CDATA[Dynamic getURL in flash]]></description>
			<content:encoded><![CDATA[<p>Today i got asked to add links to a flash animation that i have done recently. The flash animation in question has dynamic title&#8217;s and content based on two movie clips, which are built from an array of data pulled in from XML.</p>
<p>Knowing i needed to add a &#8220;getUrl()&#8221; function and &#8220;onRelease&#8221; event handler for the dynamic movie clips, I thought to myself <em>&#8220;what would be the easiest was to do this&#8230;&#8221;</em></p>
<p>With the clips being made inside a simple for loop, i hoped the data being pulled from the array would be retained and correct for when the event handler was eventually triggered (optimistic i know!). If you hadn&#8217;t already guessed this didn&#8217;t work, so off i went thinking how i can have the right data when the event handler fires.</p>
<p>After a little while and tinkering with my code i finally figured out a solution. When attaching the movieClip you can store the instance in a variable and then set a variable inside the movie clip. When the event handler is triggered it simply calls &#8220;this.linkTo&#8221; (&#8221;this&#8221;, referring to the movieClip, and &#8220;linkTo&#8221; refferring to the variable) as the getURL() address parameter</p>
<p>The code snippet for this is:</p>
<pre>
// Create new instance of the Section_Title movie clip
var SectionTitle = attachMovie("Section_Title", Sections[ii][0], ii, { _x:-230, _y:_yPos });

// Set a variable for this movie clip for the navigate link
SectionTitle.linkTo = Sections[ii][2];

// Create event handler for the click release
SectionTitle.onRelease = function(){
// Goto page save in thje movie clip linkTo variable
getURL(this.linkTo);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://danrichardson.net/blog/tech/2008/07/29/dynamic-geturl-in-flash/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

