<?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>Flash and ActionScript tutorials - flashadvanced &#187; easing</title>
	<atom:link href="http://flashadvanced.com/tag/easing/feed/" rel="self" type="application/rss+xml" />
	<link>http://flashadvanced.com</link>
	<description>Become an advanced flash developer</description>
	<lastBuildDate>Mon, 11 Jan 2010 22:14:13 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Preloader following mouse</title>
		<link>http://flashadvanced.com/advanced-actionscript-3/preloader-following-mouse/</link>
		<comments>http://flashadvanced.com/advanced-actionscript-3/preloader-following-mouse/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 19:26:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Advanced ActionScript 3]]></category>
		<category><![CDATA[easing]]></category>
		<category><![CDATA[mouse follower]]></category>
		<category><![CDATA[preloader]]></category>
		<category><![CDATA[Tooltip]]></category>
		<category><![CDATA[tween]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=385</guid>
		<description><![CDATA[


In this tutorial I will show you how to create a nice tooltip preloader with easing using Flash and ActionScript 3. We&#8217;ll be loading an external SWF file.

Note: In order to complete this tutorial you need to download TweenMax library. Do it by clicking here. Unzip the downloaded file in the same directory as the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=385"><br />
<img src="http://flashadvanced.com/wp-content/upload/preloader/preloader.jpg" alt="" /><br />
</a></p>
<p>In this tutorial I will show you how to create a nice <strong>tooltip preloader with easing</strong> using Flash and ActionScript 3. We&#8217;ll be loading an external SWF file.</p>
<p><span id="more-385"></span></p>
<h4>Note: In order to complete this tutorial you need to download TweenMax library. Do it by clicking <a href="http://blog.greensock.com/tweenmaxas3/">here</a>. Unzip the downloaded file in the same directory as the Flash files!</h4>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;preloader.fla&#8221;.</p>
<p><span style="color: #ff0000;">2.</span> Now we have to create our tooltip. If you don&#8217;t know how to draw a tooltip, see the &#8220;Tooltip&#8221; tutorial by clicking <a href="http://flashadvanced.com/?p=1" target="_blank">here</a>.<br />
If you are ready with the tooltip, select it and convert it to movie clip with instance name &#8220;tooltip_mc&#8221;. Set its registration point to <strong>bottom center</strong>:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/preloader/regpoint.jpg" alt="" /></p>
<p>Now, go inside &#8220;tooltip_mc&#8221; and create a dynamic text field on the top of the tooltip. For font select &#8220;Arial Black&#8221;, choose 9 for size and #FFFFFF for color. Type &#8220;percent_txt&#8221; for instance name. Don&#8217;t forget to embed the font:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/preloader/embed.jpg" alt="" /></p>
<p><span style="color: #ff0000;">3.</span> We are ready with the tooltip. Before we move to ActionScript we need to create another movie that we&#8217;ll be loading. <strong>Open a new flash document</strong> and import a photo that is larger than 100 Kb or you can drag several components to the stage. The idea is to make the compiled SWF file larger. Save this file under &#8220;content.fla&#8221; in the same directory as &#8220;preloader.fla&#8221; and compile it. We are going to <strong>load</strong> &#8220;content.swf&#8221;.</p>
<p><span style="color: #ff0000;">4.</span> Go back to &#8220;preloader.fla&#8221;, create a new layer called &#8220;actions&#8221; and open the actions panel:</p>
<pre><code>
//we hide the cursor
Mouse.hide();

//importing TweenMax classes
import gs.*;

//by default our tooltip should follow the mouse
TweenMax.to(tooltip_mc, 0.5 ,{x :mouseX, y: mouseY});

 //adding mouse move event handler
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

function mouseMoveHandler(e:Event):void {
	//the tooltip follows the mouse when it is moved
	TweenMax.to(tooltip_mc, 0.5, {x :mouseX, y: mouseY});
}

//creating a loader
var loader:Loader = new Loader();
//adding progress event handler to our loader
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
                                                     loadContent);
//calling "contentLoaded" function if loading is over
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentLoaded);
//loading the content
loader.load(new URLRequest("content.swf"));

function loadContent(e:ProgressEvent):void{
	//calculating the percentage loaded
	var pcent:Number = (e.bytesLoaded / e.bytesTotal) * 100;
	//adding the percentage to the text field
	tooltip_mc.percent_txt.text = int(pcent)+"%";
}

function contentLoaded(e:Event):void{
	//when the movie is loaded we remove the preloader
	removeChild(tooltip_mc);
	//then we add the loader
	addChild(loader);
	//and finally we show the cursor again
	Mouse.show();
}
</code></pre>
<h4>Here is the final result. Move your mouse over the movie:</h4>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://flashadvanced.com/wp-content/upload/preloader/sitever.swf" /><embed type="application/x-shockwave-flash" width="500" height="350" src="http://flashadvanced.com/wp-content/upload/preloader/sitever.swf"></embed></object></p>
<h4>You can test your preloader by compiling the movie and then going to View -&gt; Simulate Download</h4>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/preloader/preloader.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/advanced-actionscript-3/preloader-following-mouse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
