<?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; tween</title>
	<atom:link href="http://flashadvanced.com/tag/tween/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>
		<item>
		<title>XML random quotes rotator</title>
		<link>http://flashadvanced.com/advanced-actionscript-3/xml-random-quotes-rotator/</link>
		<comments>http://flashadvanced.com/advanced-actionscript-3/xml-random-quotes-rotator/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:37:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Advanced ActionScript 3]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[tween]]></category>
		<category><![CDATA[xml]]></category>

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


Today I will show you how to use XML and ActionScript 3 to create a small application that changes your favourite quotes after some time interval. We will be using also the AS3 Tween Class to animate the quotes&#8217; appearance.

At first this was just an experiment but i thought it might be useful for some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=169"><br />
<img src="http://www.flashadvanced.com/wp-content/upload/quotes/quotes.jpg" alt="" /><br />
</a></p>
<p>Today I will show you how to use <strong>XML</strong> and ActionScript 3 to create a small application that changes your favourite quotes after some time interval. We will be using also the AS3 <strong>Tween Class</strong> to animate the quotes&#8217; appearance.</p>
<p><span id="more-169"></span></p>
<p>At first this was just an experiment but i thought it might be useful for some of you. What the rotator does is to choose a <strong>random</strong> quote from an XML file and then shows it for several seconds. Then it chooses another random quote and so on. You can use it for header of your blog or whatever you want. So, let&#8217;s get started.</p>
<p><span style="color: #ff0000;"><strong>1.</strong></span> Create a new Flash CS3 document with size 600 x 100 and background color #000000.<br />
<span style="color: #ff0000;"><strong>2.</strong></span> Create two dynamic text fields. The first one should be about 580px wide and the second one &#8211; about 200px. For the long text field choose #ffffff for color, size 14, bold. I have used &#8220;Verdana&#8221; for font. If you don&#8217;t like it choose another font. Align the text inside the text field to center. Give it an instance name &#8220;quoteTxt&#8221;. Embed the font like this:</p>
<p><img src="http://www.flashadvanced.com/wp-content/upload/quotes/embed.jpg" alt="" /></p>
<p>Now repeat this step for the other text field but only change the color to #00CCFF and give it an instance name &#8220;authorTxt&#8221;.<br />
<span style="color: #ff0000;"><strong>3.</strong></span> Convert the text fields to movie clips. Select the long text field and convert it to movie clip with instance name &#8220;quoteMC&#8221;. Repeat the same for the other text field and put &#8220;authorMC&#8221; for instance name.<br />
<span style="color: #ff0000;"><strong>4.</strong></span> Now let&#8217;s create the <strong>XML</strong> file we will be using. You can simply download it from <a href="http://www.flashadvanced.com/wp-content/upload/quotes/quotes.xml">here</a>. So after downloading put the file into directory named &#8220;data&#8221;.<br />
<span style="color: #ff0000;"><strong>5.</strong></span> Create a new layer called &#8220;actions&#8221;, open the actions panel and paste this code:</p>
<pre><code>
//importing tween classes
import fl.transitions.Tween;
import fl.transitions.easing.*;

//we create a variable to store the loaded XML
var xml:XML;
//the path to the xml file
var xmlPath:String = "http://www.flashadvanced.com/wp-content/upload/quotes/quotes.xml";
//we create a loader and when the loading is over we call the xmlComplete function
var loader:URLLoader = new URLLoader();
//a url request for our loader
var req:URLRequest = new URLRequest(xmlPath);
loader.addEventListener(Event.COMPLETE, xmlComplete);
loader.load(req);
//a variable for our tween
var myTween:Tween;
//we need to set a timer
var timer:Timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, changeQuotes);
timer.start();

function xmlComplete(e:Event):void{
	xml = new XML(e.target.data);
	addQuotes();
	randomQuoteTween();
}

//we create arrays to store the quotes and the authors
var quotesArray:Array = new Array();
var authorsArray:Array = new Array();
//we need a random quote number
var randomNumber:Number;

function addQuotes(){
	//we loop through the "quote" element of our XML
	for each(var item:XML in xml.quotes.quote){
		//we fill the arrays with quotes and authors
		quotesArray.push(item.content);
		authorsArray.push(item.author);
	}
}

function randomQuoteTween():void{
	//calculating the random number
	randomNumber = Math.round(Math.random() * (quotesArray.length - 1));
	//filling the text fields
	quoteMC.quoteTxt.text = quotesArray[randomNumber];
	authorMC.authorTxt.text = authorsArray[randomNumber];
	//creating tween effects
	myTween = new Tween(quoteMC, "alpha", Strong.easeOut, 0, 1, 3, true);
	myTween = new Tween(authorMC, "x", Strong.easeOut, 550, 500, 3, true);
}

function changeQuotes(e:TimerEvent){
	randomQuoteTween();
}
</code></pre>
<h4>Here is the final result:</h4>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.flashadvanced.com/wp-content/upload/quotes/Quotes.swf" /><embed type="application/x-shockwave-flash" width="600" height="100" src="http://www.flashadvanced.com/wp-content/upload/quotes/Quotes.swf"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/quotes/quotes.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/advanced-actionscript-3/xml-random-quotes-rotator/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
