<?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>Wassim Sidani &#187; Flash Tutorials</title>
	<atom:link href="http://www.sidani.info/category/flash/flash-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sidani.info</link>
	<description>Education Biology Flash Animation 3D biology</description>
	<lastBuildDate>Thu, 10 Jun 2010 08:44:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Arabic text from mySQL database using amfphp</title>
		<link>http://www.sidani.info/2010/05/10/arabic-text-from-mysql-database-using-amfphp/</link>
		<comments>http://www.sidani.info/2010/05/10/arabic-text-from-mysql-database-using-amfphp/#comments</comments>
		<pubDate>Mon, 10 May 2010 18:31:39 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorials]]></category>
		<category><![CDATA[amfphp]]></category>
		<category><![CDATA[arabic]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[french]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.sidani.info/?p=134</guid>
		<description><![CDATA[I had this issue where arabic text and french text retrieved from a mySQL database were not displaying correctly in my flash frontend, I was using amfphp to communicate and query the database. Needless to say that the text does display correctly in phpMyAdmin so it is correctly encoded in the database itself.]]></description>
			<content:encoded><![CDATA[<p>I had this issue where arabic text and french text retrieved from a mySQL database were not displaying correctly in my flash frontend, I was using amfphp to communicate and query the database. Needless to say that the text does display correctly in phpMyAdmin so it is correctly encoded in the database itself.</p>
<p>So here&#8217;s what I did to resolve the issue:</p>
<p>- Ensure that the mySQL tables where the text is stored are <strong>using the utf8_general_ci Collation</strong>.</p>
<p>- Set <strong>$gateway->setCharsetHandler( &#8220;none&#8221;, &#8220;ISO-8859-1&#8243;, &#8220;ISO-8859-1&#8243; )</strong> in the gateway.php file (in case you&#8217;re wondering, yes you should simply NOT use iconv or utf_decoder or mbstring or the like, just disable the setCharsetHandler conversion by using &#8220;none&#8221; as the conversion method).</p>
<p>- in your php service file, say it&#8217;s called permissions.php, use the following : </p>
<p><code>$rsConnectionID=mysql_connect("localhost", "root", "");<br />
		mysql_set_charset("utf8", $rsConnectionID);</code></p>
<p>Be sure to have these set before running your query or passing the results to flash.</p>
<p>This should resolve all the issues you&#8217;re having, of course <strong>you should not use the following actionScript</strong> : <code>system.useCodepage = true;</code> as this will tell the flash player not to use utf 8 as default encoding and will surely get you into troubles.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2010/05/10/arabic-text-from-mysql-database-using-amfphp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A quick way to detect Idleing in flash actionscript 2</title>
		<link>http://www.sidani.info/2008/07/25/a-quick-way-to-detect-idleing-in-flash-actionscript-2/</link>
		<comments>http://www.sidani.info/2008/07/25/a-quick-way-to-detect-idleing-in-flash-actionscript-2/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 01:20:30 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2008/07/25/a-quick-way-to-detect-idleing-in-flash-actionscript-2/</guid>
		<description><![CDATA[So I had this customer who asked me to do an flv player for his site, he wanted the controls of the player to fade out when the user is idle, now flash does not have an onIdle event of any kind and the only way around this was to trigger a signal when the [...]]]></description>
			<content:encoded><![CDATA[<p>So I had this customer who asked me to do an flv player for his site, he wanted the controls of the player to fade out when the user is idle, now flash does not have an onIdle event of any kind and the only way around this was to trigger a signal when the mouse kept its position (did not move) for more than 3 second (or x seconds, customizable) or keys has not been pressed for x seconds.</p>
<p>Again, flash does not have an onMouseStill event so I had to do it this way:</p>
<p><code><br />
this.onMouseMove=function(){<br />
clearTimeout(toInt);<br />
fadeControlsIn();<br />
toInt=setTimeout(fadeOut,3000);</p>
<p>}<br />
function fadeOut(){<br />
//fading out code goes here...<br />
}<br />
function fadeControlsIn(){<br />
/fading in code goes here....</p>
<p>}<br />
</code></p>
<p>A similar approach can be applied to keypresses.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2008/07/25/a-quick-way-to-detect-idleing-in-flash-actionscript-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Left trim and right trim actionScript functions</title>
		<link>http://www.sidani.info/2008/04/25/left-trim-and-right-trim-actionscript-functions/</link>
		<comments>http://www.sidani.info/2008/04/25/left-trim-and-right-trim-actionscript-functions/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 05:56:33 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2008/04/25/left-trim-and-right-trim-actionscript-functions/</guid>
		<description><![CDATA[Left trim and right trim actionScript functions These useful functions (lTrim and rTrim) are available in almost all programming languages yet not in actionScript, so here’s how to write ones yourself: lTrim is easier, so we’ll start with that: [as] function lTrim(txt:String):String { while (txt.charAt(0)==&#8221; &#8221; &#124;&#124;txt.charAt(0)==&#8221;\t&#8221; &#124;&#124; txt.charAt(0)==&#8221;\n&#8221; &#124;&#124; txt.charAt(0)==&#8221;\r&#8221; ) { txt=txt.substring(1,txt.length-1); } [...]]]></description>
			<content:encoded><![CDATA[<p>Left trim and right trim actionScript functions<br />
These useful functions (lTrim and rTrim) are available in almost all programming languages yet not in actionScript, so here’s how to write ones yourself:<br />
lTrim is easier, so we’ll start with that:</p>
<p>[as]<br />
function lTrim(txt:String):String {<br />
	while<br />
            (txt.charAt(0)==&#8221; &#8221;<br />
            ||txt.charAt(0)==&#8221;\t&#8221;<br />
            || txt.charAt(0)==&#8221;\n&#8221;<br />
            || txt.charAt(0)==&#8221;\r&#8221;<br />
            ) {<br />
		txt=txt.substring(1,txt.length-1);<br />
	}<br />
	return txt;<br />
}<br />
//usage example:<br />
trace(lTrim(&#8221;   here&#8217;s a text to trim&#8221;));// outputs : here&#8217;s a text to trim<br />
[/as]</p>
<p>Pretty much straight forward, the function accepts a string as argument and returns a string, it checks whether the first character is a space, tab, or newline character and simply cuts it out and runs the same check on the resulting substring until there are no white spaces left at the leftmost end of the string.</p>
<p>Now for the slightly harder rTrim function,</p>
<p>[as]</p>
<p>function rTrim (txt:String):String {</p>
<p>	while (txt.charAt(txt.length-1)==&#8221; &#8221; ||txt.charAt(txt.length-1)==&#8221;\t&#8221; || txt.charAt(txt.length-1)==&#8221;\n&#8221; || txt.charAt(txt.length-1)==&#8221;\r&#8221;){<br />
		txt=txt.substring(0,txt.length-1);<br />
	}<br />
	return txt;</p>
<p>}<br />
trace(rTrim (&#8220;rtrim this please  \n\r		 &#8220;)+&#8221;delimiter&#8221;);//outputs : rtrim this pleasedelimiter</p>
<p>[/as]<br />
The logic is very similar, feel free to use these wherever you like.<br />
I would recommend using these as part of a class for string manipulation.<br />
Btw, these functions are AS2 and AS3 compatible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2008/04/25/left-trim-and-right-trim-actionscript-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>actionScript AS2 (typewriter) text effect</title>
		<link>http://www.sidani.info/2008/02/23/actionscript-as2-type-in-typewriter-text-effect/</link>
		<comments>http://www.sidani.info/2008/02/23/actionscript-as2-type-in-typewriter-text-effect/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 12:38:31 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2008/02/23/actionscript-as2-type-in-typewriter-text-effect/</guid>
		<description><![CDATA[I needed a typewriter text effect with a twist for an mp3 player I was making, looked around and could not find one that suits my needs so I wrote this class, should do the job. [as] /* @author = Wassim Sidani @www.sidani.info usage example: var tE:TxtEff=new TxtEff(textFieldInstance, textToWrite, delay); textFieldInstance= a reference to a [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a typewriter text effect with a twist for an mp3 player I was making, looked around and could not find one that suits my needs so I wrote this class, should do the job.<br />
</br></p>
<p>[as]</p>
<p> /*</p>
<p>@author = Wassim Sidani<br />
@www.sidani.info</p>
<p>usage example:</p>
<p>var tE:TxtEff=new TxtEff(textFieldInstance, textToWrite, delay);</p>
<p>textFieldInstance= a reference to a text field.</p>
<p>textToWrite= the actual text that will be typed in the text field.</p>
<p>delay = dealy in milliseconds before writing next character;</p>
<p>*/<br />
class TxtEff extends TextField<br />
{<br />
	function TxtEff (me, txt, delay)<br />
	{<br />
		//clearInterval(myInt);<br />
		//clearTimeout(myOtherIn);<br />
		myClass=this;<br />
		inite (me, txt, delay);<br />
	}<br />
	function inite (me, txt, delay)<br />
	{</p>
<p>		var j : Number = 0;<br />
		chars = ['$', '!', '"', '#', '$', '%', '&#038;', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']&#8216;, &#8216;^&#8217;, &#8216;_&#8217;, &#8216;`&#8217;, &#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;, &#8216;d&#8217;, &#8216;e&#8217;, &#8216;f&#8217;, &#8216;g&#8217;, &#8216;h&#8217;, &#8216;i&#8217;, &#8216;j&#8217;, &#8216;k&#8217;, &#8216;l&#8217;, &#8216;m&#8217;, &#8216;n&#8217;, &#8216;o&#8217;, &#8216;p&#8217;, &#8216;q&#8217;, &#8216;r&#8217;, &#8216;s&#8217;, &#8216;t&#8217;, &#8216;u&#8217;, &#8216;v&#8217;, &#8216;w&#8217;, &#8216;x&#8217;, &#8216;y&#8217;, &#8216;z&#8217;, &#8216;{&#8216;, &#8216;|&#8217;, &#8216;}&#8217;, &#8216;~&#8217;, &#8216; &#8216;];<br />
		var initialText : String = txt;<br />
		for (k = 0; k < txt.length; k ++)<br />
		{<br />
			me.replaceText (k, k + 1, &#8216;-&#8217;);<br />
		}<br />
		var myInt : Number = setInterval (go, delay, me);<br />
		function go (me)<br />
		{<br />
			//trace(&#8216;goo is called and me.text =&#8217;+me.text);<br />
			if (j < initialText.length)<br />
			{<br />
				//trace(&#8216;j is &#8216; + j+&#8221; and chars.length is &#8220;+chars.length);<br />
				for (var i = 0; i < chars.length; i ++)<br />
				{<br />
					if (initialText.charAt (j) == chars [i])<br />
					{<br />
						me.replaceText (j, j + 1, chars [i]);<br />
						j ++;<br />
						break;<br />
					}<br />
				}<br />
			} else<br />
			{<br />
				clearInterval (myInt);<br />
				trace (&#8220;done j=&#8221; + j);<br />
				//myOtherIn=setTimeout(myClass.inite,3000,me,txt,delay);<br />
			}<br />
		}<br />
	}</p>
<p>}</p>
<p>[/as]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2008/02/23/actionscript-as2-type-in-typewriter-text-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash scrollPane component scrollbar not showing up</title>
		<link>http://www.sidani.info/2007/12/23/flash-scrollpane-component-scrollbar-not-showing-up-when-it-should/</link>
		<comments>http://www.sidani.info/2007/12/23/flash-scrollpane-component-scrollbar-not-showing-up-when-it-should/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 01:17:04 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2007/12/23/flash-scrollpane-component-scrollbar-not-showing-up-when-it-should/</guid>
		<description><![CDATA[This fix applies to flash 8 scrollPane component v2. Here&#8217;s the problem: you attach content dynamically at runtime to your scrollPane, then much to your surprise, the vertical scroll bar doesn&#8217;t show up despite the fact that you specified vScrollPolicy as &#8220;on&#8221; or &#8220;auto&#8221; and that the content is larger than the scrollPane. You probably [...]]]></description>
			<content:encoded><![CDATA[<p>This fix applies to flash 8 scrollPane component v2.
</p>
<p>Here&#8217;s the problem: you attach content dynamically at runtime to your scrollPane, then much to your surprise, the vertical scroll bar doesn&#8217;t show up despite the fact that you specified vScrollPolicy as &#8220;on&#8221; or &#8220;auto&#8221; and that the content is larger than the scrollPane.
</p>
<p>You  probably know the problem that&#8217;s why you are here! Google dropped you in the right place, I have found a solution! A working fix.
</p>
<p>After searching for two hours, and trying all the suggested workarounds like calling the redraw() method on the instance or the onComplete(), doLater() or even the invalidate() method, none of these worked, I even tried lowering the frame rate of the movie but all this ended up failing so I started experimenting and I found the following:
</p>
<p>If you change the position of the content clip inside your scroll pane component, the scroll bar will fail to account for this change, it might even not appear in the first place, if you add content dynamically, like attaching a movieClip from the library on runtime, you will also face issues with the scroll bar.
</p>
<p>What I did to solve the issue and debug is that I simply called the setSize() method twice, in the first call, I assigned a height higher than the desired one then in the second call, I assigned the desired height and this worked ! the scroll bar of the scrollpane now appears and behaves as expected.
</p>
<p>Note that this fixed the case where the content is being attached from the library, not loaded externally.
</p>
<p>
 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2007/12/23/flash-scrollpane-component-scrollbar-not-showing-up-when-it-should/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flash Player cache and smaller swf files</title>
		<link>http://www.sidani.info/2007/12/04/flash-player-cache-and-smaller-swf-files/</link>
		<comments>http://www.sidani.info/2007/12/04/flash-player-cache-and-smaller-swf-files/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 23:24:25 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2007/12/04/flash-player-cache-and-smaller-swf-files/</guid>
		<description><![CDATA[This new feature has been introduced in flash player 9,0,115,0.  Certain standard flash components (dataGrid, comboBox, list etc..) are used by a large number of websites. For example, More than 100 Kb of identical data has to be downloaded for every Flex application (the flex framework) . With the new Flash Player cache, Flex applications [...]]]></description>
			<content:encoded><![CDATA[<p>This new feature has been introduced in flash player 9,0,115,0.
</p>
<p> Certain standard flash components (dataGrid, comboBox, list etc..) are used by a large number of websites. For example, More than 100 Kb of identical data has to be downloaded for every Flex application (the flex framework) . With the new Flash Player cache, Flex applications will download and start up much faster because users will probably have the framework already in a special cache from one site and will not need to download it again.
</p>
<p>The Flash Player cache is not the same as the browser&#8217;s cache. It works by storing the contents of a new type of file (SWZ) on your hard drive. When a website makes a request for the SWZ file from the server, Flash Player first checks to see whether it has the matching file already in the cache before attempting to download it.
</p>
<p> Besides providing smaller size advantage and thus faster loading, this feature is also beneficial to the application host by reducing bandwidth. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2007/12/04/flash-player-cache-and-smaller-swf-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash is growing fast!</title>
		<link>http://www.sidani.info/2007/11/06/flash-is-growing-fast/</link>
		<comments>http://www.sidani.info/2007/11/06/flash-is-growing-fast/#comments</comments>
		<pubDate>Tue, 06 Nov 2007 19:20:27 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2007/11/06/flash-is-growing-fast/</guid>
		<description><![CDATA[It is a fact, flash is growing fast and the new changes to its scripting language i.e. actionScript3 is the most radical change, being a professional AS2 programmer, I find myself amazed of how much things have changed in the new language, the web is full of articles talking about the transition from AS2 to [...]]]></description>
			<content:encoded><![CDATA[<p>It is a fact, flash is growing fast and the new changes to its scripting language i.e. actionScript3 is the most radical change, being a professional AS2 programmer, I find myself amazed of how much things have changed in the new language, the web is full of articles talking about the transition from AS2 to AS3, Adobe site contains a whole section about this yet I still find the introduced changes a bit of too much!
</p>
<p>If I were in Adobe shoes, I would have provided AS2 experts with the same functionality using the existing language and added the new one as well, like they did with director when they introduced javascript in addition to director&#8217;s native scripting language &#8220;Lingo&#8221;.
</p>
<p>AS3 offers better OOP practice, ok, I agree, but who said that matters for us web developers? We were happy with the ugly non OOP language we had; it was working well for us and the fact that a new version of flash i.e. CS3 emerged is the single proof of the popularity of this program and what it offered to the web.
</p>
<p>Wherever you go, you see the fuss about classes, packages, cryptic error codes and more of the like, my guess is that AS3 wont be accepted by flash developers as fast as Adobe wish, I know I am not accepting it and wont do commercial jobs using it, no sir, I will stick to my good old AS2 and wait till adobe finish the upgrades and add the new beta features like high definition video and audio support (btw, work on flash player 10 is in its last stages, and words about flash CS4 with a set of new features is also spreading in the flash community), with the rate things are moving at, I guess I wont have time to play with CS3 since by the time I decide to dive in it, CS4 will probably be out and running…
</p>
<p>
 </p>
<p>More on this in the coming few days.
</p>
<p>
 </p>
<p>
 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2007/11/06/flash-is-growing-fast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Part 2 of data binding tutorial.</title>
		<link>http://www.sidani.info/2007/07/22/part-2-of-data-binding-tutorial/</link>
		<comments>http://www.sidani.info/2007/07/22/part-2-of-data-binding-tutorial/#comments</comments>
		<pubDate>Sun, 22 Jul 2007 22:10:50 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2007/07/22/part-2-of-data-binding-tutorial/</guid>
		<description><![CDATA[Hello again, In part one, we saw an easy way to use the XML connector and dataBinding component to assign the contentPath propery of the media player component to one entry of an XML playlist. In this tutorial, we go one step further and add a dataGrid then bind the selected index of that grid [...]]]></description>
			<content:encoded><![CDATA[<p>Hello again,</p>
<p>In part one, we saw an easy way to use the XML connector and dataBinding component to assign the contentPath propery of the media player component to one entry of an XML playlist.</p>
<p>In this tutorial, we go one step further and add a dataGrid then bind the selected index of that grid to the contentPath of the media Player component.</p>
<p>Before going further in this explanation, have a look here : </p>
<p><A HREF="http://www.sidani.info/test/xmc/glassMp3Player.html "> Custom MP3 Player-Glassy look </A></p>
<p>So how we do that?</p>
<p>First, the dataProvider property of the dataGrid has to be linked to the result of the XML parameter and more precisely to the array object in the results.</p>
<p>This ensures automatic parsing of the XML data into a bidimensional array which the dataGrid can use as a dataProvider.</p>
<p>Then, we use this code to listen to cell press event  and to respond accordingly :<br />
<code><br />
myListener = new Object();<br />
myListener.change = function(evtObj) {<br />
mp.contentPath = dg.selectedItem.location;<br />
}<br />
dg.addEventListener("change",myListener);<br />
</code></p>
<p>Where dg is the instance name of the dataGrid component and mp is that of the mediaPlayer component.</p>
<p>I&#8217;ve uploaded 4 songs I found on my HD, they do not correspond to the entries in the XML playlist yet that what I have for now so <img src='http://www.sidani.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8230;</p>
<p>Till the next tutorial, stay safe and don&#8217;t do stupid things !</p>
<p>Bye.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2007/07/22/part-2-of-data-binding-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML connector and Data binding tutorial.</title>
		<link>http://www.sidani.info/2007/05/25/xml-connector-and-data-binding-tutorial/</link>
		<comments>http://www.sidani.info/2007/05/25/xml-connector-and-data-binding-tutorial/#comments</comments>
		<pubDate>Fri, 25 May 2007 21:48:44 +0000</pubDate>
		<dc:creator>wassim</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2007/05/25/xml-connector-and-data-binding-tutorial/</guid>
		<description><![CDATA[Hello guys, It’s been a while and I was very busy , could not get this data binding and XML connector tutorial posted. Excuse my delay. So here is the long waited xml connector and data biniding tutorial at last! Ok, let’s explain few things before we start. XML connector is a class whose job [...]]]></description>
			<content:encoded><![CDATA[<p>Hello guys,<br />
It’s been a while and I was very busy , could not get this data binding and XML connector tutorial posted. Excuse my delay.<br />
So here is the long waited xml connector and data biniding tutorial at last!</p>
<p>Ok, let’s explain few things before we start.</p>
<p>XML connector is a class whose job is to make loading and parsing XML much easier.<br />
Data binding provides an easy way to link various components to each other and to the XML connector (or data holder).</p>
<p>The following example explains how this works.<br />
Let’s look at this simple XML file :<br />
[xml]<br />
<?xml version="1.0" encoding="UTF-8" ?><br />
- <Total_songs><br />
  <song path="music/sit_down.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Sit Down, Shut Up" /><br />
  <song path="music/be_kind_to_me.mp3" art="art/number1.jpg" bands="Number 1, I Love You" titles="Be Kind To Me (Demo)" /><br />
  <song path="music/shoot_me_in_the_spine.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Shoot Me In The Spine" /><br />
  <song path="music/we_awoke.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="We Awoke" /><br />
  <song path="music/sit_down.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 5" /><br />
  <song path="music/be_kind_to_me.mp3" art="art/number1.jpg" bands="Number 1, I Love You" titles="Track 6" /><br />
  <song path="music/shoot_me_in_the_spine.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 7" /><br />
  <song path="music/we_awoke.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 8" /><br />
  <song path="music/sit_down.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 9" /><br />
  <song path="music/be_kind_to_me.mp3" art="art/number1.jpg" bands="Number 1, I Love You" titles="Track 10" /><br />
  <song path="music/shoot_me_in_the_spine.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 11" /><br />
  <song path="music/we_awoke.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 12" /><br />
  <song path="music/be_kind_to_me.mp3" art="art/number1.jpg" bands="Number 1, I Love You" titles="Track 13" /><br />
  <song path="music/shoot_me_in_the_spine.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 14" /><br />
  <song path="music/we_awoke.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 15" /><br />
  <song path="music/sit_down.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 16" /><br />
  <song path="music/be_kind_to_me.mp3" art="art/number1.jpg" bands="Number 1, I Love You" titles="Track 17" /><br />
  <song path="music/shoot_me_in_the_spine.mp3" art="art/these_dungarees.jpg" bands="These Dungarees" titles="Track 18" /><br />
  </Total_songs></p>
<p>[/xml]</p>
<p>Let’s assume you want to build a cool mp3 player that plays songs provided by a playlist like the one this XML represents. If you’re going to do this the classical way, then prepare yourself for lots and lots of parsing and coding…<br />
Using the XML connector together with data binding will make this task a joke!</p>
<p>So the first thing you need to do is to drag a media player and an XML connector component to the stage, give the former the instance name of mp  and give the latter an instance name of “xmc”.</p>
<p>Place your xmc off stage, click on it and open up the component inspector, type the path to the playlist xml file, in our case it’s simply songs.xml as it resides with the swf in the same folder.</p>
<p>Now, click on the schema tab and then click on the  “import a schema from a sample xml” button then browse to the songs.xml itself and click ok.</p>
<p>At this point, you’ll see the xml schema displayed, we’re particularly interested in the path to the mp3 file that the player has to read, so practically we need to grab the Path attribute (@Path).</p>
<p>Now comes the interesting part, click on the biniding tab in the component inspector then click on the “+” sign to add a binding, the same xml schema appears, click on the Path attribute then click Ok.</p>
<p>Now, in the grid below, choose out as direction from the drop down list, double click on the bound to field and from the dialog that appears choose the media player component and from the right hand side panel choose contentPath as the property of the mediaplayer to which the Path attribute will be bound to.</p>
<p>One last thing, put the following code on frame one of your timeline : </p>
<p>[as]xmc.trigger();[/as]</p>
<p>Without this, the xml connector will not function at all.</p>
<p>Now what we have is a mediaPlayer component that reads the first node in the xml, parses the path attribute and loads that as contentPath and start playing it! </p>
<p>Check the sample below.</p>
<p>That’s cool but what about other songs? How can we choose to play those?<br />
Well, I will leave that to another tutorial…</p>
<p>mp3 player reading from XML and databinding<br />
Here&#8217;s the page where you can see the XML connector and the mp3 player:</p>
<p><a href="http://www.sidani.info/test/xmc/">Click Here </a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2007/05/25/xml-connector-and-data-binding-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML connector and Data binding tutorial soon</title>
		<link>http://www.sidani.info/2007/03/11/xml-connector-and-data-binding-tutorial-soon/</link>
		<comments>http://www.sidani.info/2007/03/11/xml-connector-and-data-binding-tutorial-soon/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 21:24:39 +0000</pubDate>
		<dc:creator>Tarek</dc:creator>
				<category><![CDATA[Flash Tutorials]]></category>

		<guid isPermaLink="false">http://www.sidani.info/2007/03/11/xml-connector-and-data-binding-tutorial-soon/</guid>
		<description><![CDATA[Hello, Expect a new hot tutorial about XML connector and Data binding soon… These two are among the least known and understood, they however are truely time saving and extremely powerful. It will be up within two or three days. Regards]]></description>
			<content:encoded><![CDATA[<p>Hello, </p>
<p>Expect a new hot tutorial about XML connector and Data binding soon…</p>
<p>These two are among the least known and understood, they however are truely time saving and extremely powerful.</p>
<p>It will be up within two or three days.</p>
<p>Regards</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sidani.info/2007/03/11/xml-connector-and-data-binding-tutorial-soon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
