<?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; xml</title>
	<atom:link href="http://flashadvanced.com/tag/xml/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>Using Flash CS3 components, Part 1</title>
		<link>http://flashadvanced.com/actionscript-3-basics/using-flash-cs3-components-part-1/</link>
		<comments>http://flashadvanced.com/actionscript-3-basics/using-flash-cs3-components-part-1/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 21:21:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[list component]]></category>
		<category><![CDATA[ListEvent]]></category>
		<category><![CDATA[xml]]></category>

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


In this collection of tutorials I will show you the power of the Flash CS3 components and how to use them in the best way.
I am going to start with the List component. I will show you how to easily populate XML data into the List.

The Flash components are very useful, powerful and easy to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=295"><br />
<img src="http://flashadvanced.com/wp-content/upload/components/comp1.jpg" alt="" /><br />
</a></p>
<p>In this collection of tutorials I will show you the power of the Flash CS3 <strong>components</strong> and how to use them in the best way.<br />
I am going to start with the <strong>List component</strong>. I will show you how to easily <strong>populate XML data</strong> into the List.</p>
<p><span id="more-295"></span></p>
<p>The Flash components are very useful, powerful and easy to customize. Some of them are ComboBox, CheckBox, DataGrid and so on. You can see them in the Components panel by clicking Window -&gt; Components. Now I will show you the best and the fastest way,  in my opinion, to <strong>populate data from an XML file</strong>. We&#8217;ll be using the List component. The List component is a scrollable single- or multiple-selection list box. To add an item to the List you can use addItem() and addItemAt() methods. A List item has two properties: label and data.<br />
Let&#8217;s get started with the example.</p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash CS3 document and save it under &#8220;listXML.fla&#8221;. Set the size to 250 x 350 and for background color choose #CCCCCC. On the top of the document create a static text field and write &#8220;My favourite movies list&#8221;.<br />
<span style="color: #ff0000;">2.</span> Go to the Components panel by clicking Window -&gt; Components and drag a List component on the stage. Make it 250px wide by 300px high. Give it an instance name &#8220;xmlList&#8221;.<br />
<span style="color: #ff0000;">3.</span> Now let&#8217;s create a new XML file. I made an XML with my favourite movies. You can copy it or you can list your favourite movies.</p>
<pre><code>
&lt;?xml version = "1.0" encoding = "UTF-8"?&gt;
&lt;data&gt;
  &lt;movies&gt;
    &lt;movie&gt;
      &lt;title&gt;The Shawshank Redemption&lt;/title&gt;
      &lt;link&gt;http://www.imdb.com/title/tt0111161/&lt;/link&gt;
   &lt;/movie&gt;
   &lt;movie&gt;
     &lt;title&gt;The Godfather&lt;/title&gt;
     &lt;link&gt;http://www.imdb.com/title/tt0068646/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Lock, stock and two smoking barrels&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0120735/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;I am Sam&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0277027/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Oldboy&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0364569/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Training day&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0139654/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Live flesh&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0118819/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Liar Liar&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0119528/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Carlito's way&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0106519/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Blow&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0221027/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;The bank job&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0200465/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Big fish&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0319061/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;25th hour&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0307901/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Scarface&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0086250/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;movie&gt;
    &lt;title&gt;Alfie&lt;/title&gt;
    &lt;link&gt;http://www.imdb.com/title/tt0375173/&lt;/link&gt;
  &lt;/movie&gt;
  &lt;/movies&gt;
&lt;/data&gt;
</code></pre>
<p>Save the file under &#8220;list.xml&#8221;. It should be in the same directory as the .fla file.</p>
<p>The main idea is to populate the XML data into a List component and then set a List event.  On <strong>double click</strong> we will navigate to the movie presentation on <a href="http://imdb.com">IMDB</a> (Internet Movie DataBase) site. </p>
<p><span style="color: #ff0000;">4.</span> Go back to Flash and create a new layer called &#8220;actions&#8221;. Open the Actions Panel.</p>
<pre><code>
//we need a ListEvent for our List
import fl.events.ListEvent;

//we create a variable to store the loaded XML
var xml:XML;
//the path to the xml file
var xmlPath:String = "list.xml";
//we create a loader and when the loading is over we call the xmlLoaded function
var loader:URLLoader = new URLLoader();
//a url request for our loader
var req:URLRequest = new URLRequest(xmlPath);
loader.addEventListener(Event.COMPLETE, xmlLoaded);
loader.load(req);

//adding a double click event handler to the list
xmlList.addEventListener(ListEvent.ITEM_DOUBLE_CLICK, itemDoubleClicked)

function xmlLoaded(event:Event):void{
	//this will be the List item object
	var item:Object;
	xml = new XML(event.target.data);

	//looping through the XML nodes
	for each(var movieItem:XML in xml.movies.movie){
		//creating a new item object
		item = new Object();
		//the part that the user sees
		item.label = movieItem.title.toString();
		//we store the URL for every movie presentation
		item.data = movieItem.link.toString();
		//we add the items to the List
		xmlList.addItem(item);
	}
}

function itemDoubleClicked(event:ListEvent):void{
	//here we store the selected item's link
	var linkTo:String = xmlList.selectedItem.data.toString();
	//on double click we navigate to the movie presentation
	navigateToURL(new URLRequest(linkTo));
}
</code></pre>
<p>That was all!</p>
<h4>See how it looks:</h4>
<p><object width="250" height="350"><param name="movie" value="http://flashadvanced.com/wp-content/upload/components/listXML.swf"><embed src="http://flashadvanced.com/wp-content/upload/components/listXML.swf" width="250" height="350"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/components/listXML.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/actionscript-3-basics/using-flash-cs3-components-part-1/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>
