<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8107625831108404275</id><updated>2012-01-03T06:45:01.572+05:30</updated><category term='Tween Class'/><category term='Action Script 3'/><title type='text'>Welcome to wonderful world of Flash ActionScript</title><subtitle type='html'>Free &amp;amp; Easy Flash ActionScript tutorials for fast and effective learning</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-5169243153857199437</id><published>2009-10-26T09:33:00.000+05:30</published><updated>2009-10-26T09:33:03.809+05:30</updated><title type='text'>Create a Dynamic and Interactive Message Board in ActionScript 3</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_s6gSPX95als/SuUe3tl_tfI/AAAAAAAAAYI/Kej7PCjTkBQ/s1600-h/3.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;This tutorial is on a project made by my friend Peter Blaho(warloxk@gmail.com)&lt;br /&gt;The message board will be dyanmic in the sense that it will load the text from an external XML file.&lt;br /&gt;To start hit Ctrl+J to bring up the Document properties window. Set the width to 400 pixels and the heigh to 60. Set any background color.It won't be visible&lt;br /&gt;Draw a 400x60 Rectangle with the color #F4EED4. Align its centre so that it completely covers the stage.&lt;br /&gt;Create a new layer and name it Actions.&lt;br /&gt;&lt;br /&gt;Now Hit Ctrl+F8 to bring up the New Symbol window. Set its name to trigger_left and select Export For Actionsript.Go to the Color Window and set the type to Linear.Set the color of the left end color marker to #F4EED4 and alpha to 100%. Set the right one to #F4EED4 and this time the alpha to 0%. &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_s6gSPX95als/SuUe0zdZnjI/AAAAAAAAAX4/unjaBWNNxuY/s1600-h/1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_s6gSPX95als/SuUe0zdZnjI/AAAAAAAAAX4/unjaBWNNxuY/s320/1.bmp" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;Draw a 60x60 square and go to the Align panel to align the left edge. It should look like this&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_s6gSPX95als/SuUe2_basxI/AAAAAAAAAYA/1wzy_KJJ5Fs/s1600-h/2.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_s6gSPX95als/SuUe2_basxI/AAAAAAAAAYA/1wzy_KJJ5Fs/s320/2.bmp" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now repeat the same process but instead of the left orientaion, it should be right. Set the name as trigger_right. This should look like this&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_s6gSPX95als/SuUe3tl_tfI/AAAAAAAAAYI/Kej7PCjTkBQ/s1600-h/3.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_s6gSPX95als/SuUe3tl_tfI/AAAAAAAAAYI/Kej7PCjTkBQ/s320/3.bmp" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;Open the New Symbol window again and set the name to trigger_bottom. Remember to select Export For Actionscript. Draw a 300x60 rectangle of any color. Align its centre and set its alpha to 0.&lt;br /&gt;&lt;br /&gt;Now select the first frame of the Actions Layer and copy and paste the following code&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//////////////////////////////////////////////&lt;br /&gt;// FlashVars&lt;br /&gt;var flash_vars:Array = new Array();&lt;br /&gt;&lt;br /&gt;var keyStr:String;&lt;br /&gt;var valueStr:String;&lt;br /&gt;var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;&lt;br /&gt;for (keyStr in paramObj) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; valueStr = String(paramObj[keyStr]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flash_vars[keyStr] = valueStr;&lt;br /&gt;}&lt;br /&gt;//////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;var text_array:Array = new Array();&lt;br /&gt;var curr_text_id:int = 0;&lt;br /&gt;var text_speed:int = 2;&lt;br /&gt;var text_speed_s:int = text_speed;&lt;br /&gt;var margin:int = 10;&lt;br /&gt;&lt;br /&gt;////////////////////////////////////////////////&lt;br /&gt;var myTextField:TextField = new TextField();&lt;br /&gt;addChild(myTextField);&lt;br /&gt;var myFormat:TextFormat = new TextFormat();&lt;br /&gt;&lt;br /&gt;var trigger_left_t:trigger_left = new trigger_left;&lt;br /&gt;trigger_left_t.x = 0;&lt;br /&gt;trigger_left_t.y = 30;&lt;br /&gt;addChild(trigger_left_t);&lt;br /&gt;&lt;br /&gt;var trigger_bottom_t:trigger_bottom = new trigger_bottom;&lt;br /&gt;trigger_bottom_t.x = 200;&lt;br /&gt;trigger_bottom_t.y = 30;&lt;br /&gt;addChild(trigger_bottom_t);&lt;br /&gt;&lt;br /&gt;var trigger_right_t:trigger_right = new trigger_right;&lt;br /&gt;trigger_right_t.x = 400;&lt;br /&gt;trigger_right_t.y = 30;&lt;br /&gt;addChild(trigger_right_t);&lt;br /&gt;////////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;////////////////////////////////////////////////&lt;br /&gt;// load xml&lt;br /&gt;var xml_loader:URLLoader; //the xml loader&lt;br /&gt;flash_vars['xml_path'] = 'message.xml';&lt;br /&gt;//loadXML(flash_vars['xml_path'] + "?ticker=" + Math.random() * 1.000000E+010); //load the xml&lt;br /&gt;loadXML(flash_vars['xml_path']); //load the xml&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;function loadXML(Uri:String):void {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xml_loader = new URLLoader();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xml_loader.addEventListener(Event.COMPLETE, on_complete);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xml_loader.addEventListener(IOErrorEvent.IO_ERROR, on_error);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xml_loader.load(new URLRequest(Uri));&lt;br /&gt;}&lt;br /&gt;////////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;function on_error(evt:ErrorEvent):void {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trace("cannot load xml file");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function on_complete(evt:Event):void {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_array = get_xml_data(xml_loader.data.toString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.htmlText = text_array[curr_text_id].msg;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.width = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.x = 400 + margin;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.y = 16;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.selectable = false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.autoSize = TextFieldAutoSize.LEFT;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myFormat.color = 0x000000; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myFormat.size = 24;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.setTextFormat(myFormat);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function get_xml_data(XMLData:String):Array {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var menuXML:XML = new XML(XMLData);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //just in case&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; menuXML.ignoreWhitespace = true;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //get XML item's entrys&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var XMLItems = menuXML.descendants("core");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //load all items into an array&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var itemsArray:Array = new Array();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var itemObj:Object;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var i in XMLItems) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; itemObj=new Object();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; itemObj.msg = str_replace('[', '&amp;lt;', str_replace(']', '&amp;gt;', XMLItems[i].@msg));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; itemObj.msg_link = XMLItems[i].@msg_link;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; itemsArray.push(itemObj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return itemsArray;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function main_function(event:Event) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var max:int = myTextField.width;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (myTextField.x &amp;lt;= ((0 - max) - margin)) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if ((text_array.length - 1) &amp;gt; curr_text_id) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; curr_text_id++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; curr_text_id = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.x = 700 + margin;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.htmlText = text_array[curr_text_id].msg;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.setTextFormat(myFormat);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.autoSize = TextFieldAutoSize.LEFT;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (myTextField.x &amp;gt; 710) myTextField.x = 710;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTextField.x -= text_speed;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function text_speed_up(event:MouseEvent):void {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_speed *= 2;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function text_reverse(event:MouseEvent):void {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_speed = 0 - text_speed;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function text_normal(event:MouseEvent):void {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_speed = text_speed_s;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function text_stop(event:MouseEvent):void {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_speed = 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function str_replace(search, replace, string):String {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var array = string.split(search);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return array.join(replace);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;addEventListener(Event.ENTER_FRAME, main_function);&lt;br /&gt;trigger_left_t.addEventListener(MouseEvent.MOUSE_OVER, text_reverse);&lt;br /&gt;trigger_left_t.addEventListener(MouseEvent.MOUSE_OUT, text_normal);&lt;br /&gt;trigger_bottom_t.addEventListener(MouseEvent.MOUSE_OVER, text_stop);&lt;br /&gt;trigger_bottom_t.addEventListener(MouseEvent.MOUSE_OUT, text_normal);&lt;br /&gt;trigger_right_t.addEventListener(MouseEvent.MOUSE_OVER, text_speed_up);&lt;br /&gt;trigger_right_t.addEventListener(MouseEvent.MOUSE_OUT, text_normal);&lt;br /&gt;&lt;br /&gt;Hit Ctrl+Enter to test the movie.&lt;br /&gt;&lt;br /&gt;Download the .fla file&lt;a href="http://www.fileden.com/files/2009/9/5/2565234/messageboard.zip"&gt; here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Upload your files for free at &lt;a href="http://www.fileden.com/"&gt;www.fileden.com&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-5169243153857199437?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/5169243153857199437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/10/create-dynamic-and-interactive-message.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5169243153857199437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5169243153857199437'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/10/create-dynamic-and-interactive-message.html' title='Create a Dynamic and Interactive Message Board in ActionScript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_s6gSPX95als/SuUe0zdZnjI/AAAAAAAAAX4/unjaBWNNxuY/s72-c/1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-6901415411955297669</id><published>2009-09-22T19:34:00.001+05:30</published><updated>2009-09-23T00:25:44.925+05:30</updated><title type='text'>Create an Advanced Explosion/Fireworks Effect</title><content type='html'>&lt;div align="middle"&gt;&lt;br /&gt;&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="spark" width="400" align="middle" height="400"&gt;&lt;br /&gt;&lt;param name="allowScriptAccess" value="sameDomain"&gt;&lt;br /&gt;&lt;param name="allowFullScreen" value="false"&gt;&lt;br /&gt;&lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/NewF/spark.swf"&gt;&lt;br /&gt;&lt;param name="quality" value="high"&gt;&lt;br /&gt;&lt;param name="bgcolor" value="#222222"&gt;&lt;br /&gt;&lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/NewF/spark.swf" quality="high" bgcolor="#222222" name="spark" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="400" align="middle" height="400"&gt;&lt;/embed&gt;&lt;br /&gt;&lt;/object&gt;&lt;br /&gt;&lt;/div&gt;I will be using a 400x400 Stage with a background color of 0x222222.&lt;br /&gt;In the root directory of the .fla file create a new folder and name it script. Now open you favourite text editor and copy and paste the following code&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;package&lt;/span&gt;&lt;span style="font-style: italic;"&gt; script&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;import flash.display.Sprite;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.events.Event;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.utils.Timer;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.events.TimerEvent;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;public class&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Spark &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;extends Sprite&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; spark:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Sprite = new Sprite&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*origination coordinates of the spark*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; X;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Y;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*the Y coordinate at which the spark will busrst*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; burstPoint;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*sppeds along the X and Y axes*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; xSpeed;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; ySpeed;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*whether the spark will burst or jus fade away*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; willBurst;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*the size(width) of the spark*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; size;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*gravity will be acting on all sparks.*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; gravity = 0.15;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*flag the spark for removal*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; removeSpark = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;        /*&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            *The Constructor takes parameters in the following order&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            X Coordinate,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            Y Coordinate,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            burstPoint,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            vertical Speed,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            Horizontal Speed,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            willBurst,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            size.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            Only the first three are mandatory&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;public function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  Spark(xc:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,yc:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,brstPnt:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,ySd:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=2,&lt;br /&gt;xSd:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0,burst:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Boolean&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,sz:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=2) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            X=xc;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            Y=yc;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            burstPoint=brstPnt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            ySpeed=ySd;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            xSpeed=xSd;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            willBurst=burst;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            size=sz;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=X;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=Y;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(spark);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(Event.ENTER_FRAME&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,moveDown);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  moveDown(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;span style="color:gray;"&gt;/*if the spark is flagged for removal*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(removeSpark)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.clear&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;removeEventListener(Event.ENTER_FRAME&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,moveDown);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                spark=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;null&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; return&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;span style="color:gray;"&gt;/*Increment the Y axis speed to simulate gravity*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            ySpeed+=gravity;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;span style="color:gray;"&gt;/*Move the spark*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+=ySpeed;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+=xSpeed;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;span style="color:gray;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;span style="color: rgb(102, 102, 102);"&gt;Draw the spark and simulate the trail.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                If the spark will ultimately burst it &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                has a shorter trail. The trail also &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                depends on the speed of the spark;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;            */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.clear&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(willBurst)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i=0;i&lt;5;i+=1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineStyle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(size,0xFFFFFF,1/(i+1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.moveTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(-xSpeed*i/3,-ySpeed*i/3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(-xSpeed*(i+1)/3,-ySpeed*(i+1)/3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;span style="color:gray;"&gt;/*reduce the alpha*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-=0.02;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                if(spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;=0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    removeSpark=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;span style="color:gray;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    &lt;span style="color: rgb(102, 102, 102);"&gt;the trail length will reduce as the &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                    alpha falls to simulate a &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                    simutaneous fade out and slow down &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                    effect&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                for(i=0;i&lt;15*spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;i+=1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineStyle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(size,0xFFFFFF,1/(i+1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.moveTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(-xSpeed*i,-ySpeed*i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(-xSpeed*(i+1),-ySpeed*(i+1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                }                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;span style="color:gray;"&gt;/*If the burst Point has been reached*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            if(spark.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;=burstPoint)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;span style="color:gray;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    &lt;span style="color: rgb(102, 102, 102);"&gt;if the spark does not have to burst&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                    flag it for removal&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(!willBurst)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    removeSpark=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;span style="color:gray;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    &lt;span style="color: rgb(102, 102, 102);"&gt;the burst effect will be obtained by &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                    creating a random number of instances&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                    of the Spark class and sending them &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                    in random directions;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;                */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;else &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                {   &lt;span style="color:gray;"&gt;/*number of fragments will range from 20-40*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; burstFragments = 20+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.ceil(Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*20);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; j=0;j&amp;lt;burstfragments;j++)&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var &lt;/span&gt;&lt;span style="font-style: italic;"&gt;d:Spark =&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Spark(spark.x,burstPoint,burstPoint-100,-7+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*14,-7+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*14,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                        addChild(d);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    &lt;span style="color:gray;"&gt;/*flag the original spark for removal*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                    removeSpark=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//class ends&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//package ends&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will be your custom class. Save this file in the folder named "script", with the name "Spark.as". Now open your .fla file and hit Ctrl+J to bring up the Document Properties window and set both the Width and Height to 400 and the Background Color to0x222222 (Black).&lt;br /&gt;Click on Ok and then select the first frame of the layer and hit F9. In the Actions window that pops up, Copy the following lines of code.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;import&lt;/span&gt;&lt;span style="font-style: italic;"&gt; script.Spark;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  showSpark() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*random X coordinate of origin*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; X = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*400;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;variable xSpeed so that sparks originating&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;        from the left side of the stage move towards &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;        the right and vice-versa&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;    */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; xSpeed = 0.05*(200-X);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;random burst point so that each spark&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;        bursts at a different level&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;    */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; burstPoint = 50+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*100;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; d:Spark = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Spark(X,350,burstPoint,-15,xSpeed,true,3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    addChild(d);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*add a random shade to the spark*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    var color:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;ColorTransform&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new ColorTransform&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    color.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;blueMultiplier&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    color.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;greenMultiplier&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    d.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;transform.colorTransform&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = color;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;showSpark();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hit Ctrl+Enter To test the movie. The code will add only one instance of the Spark class to the stage. Add your own method to add more instances&lt;br /&gt;&lt;br /&gt;Download the orginal source code files &lt;a href="http://www.fileden.com/files/2009/9/5/2565234/NewF/Spark.zip"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can improve the code by adding sounds to each explosions&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-6901415411955297669?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/6901415411955297669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-advanced-explosionfireworks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/6901415411955297669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/6901415411955297669'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-advanced-explosionfireworks.html' title='Create an Advanced Explosion/Fireworks Effect'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-2724188001776870091</id><published>2009-09-19T08:34:00.000+05:30</published><updated>2009-09-19T08:49:07.896+05:30</updated><title type='text'>Imitate the Flash CS4 Color Palette in Actionscript 3</title><content type='html'>&lt;div align="middle"&gt;&lt;br /&gt;	&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="colors" align="middle" height="240" width="400"&gt;&lt;br /&gt;	&lt;param name="allowScriptAccess" value="sameDomain"&gt;&lt;br /&gt;	&lt;param name="allowFullScreen" value="false"&gt;&lt;br /&gt;	&lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/refl/colors.swf"&gt;&lt;param name="quality" value="high"&gt;&lt;param name="bgcolor" value="#000000"&gt;	&lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/refl/colors.swf" quality="high" bgcolor="#000000" name="colors" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" align="middle" height="240" width="400"&gt;&lt;/embed&gt;&lt;br /&gt;	&lt;/object&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Open your .fla file and hit Ctrl+J to bring up the Document Properties window. Change the height and width to 400 and 240 pixels respectively and the Background color to 0x000000(Black)&lt;br /&gt;Select the first frame and Hit F9 to bring up the Actions window. Copy and Paste the following code&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;/*size of each small square representing a color*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; squareSize=13;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;/*number of small squares in each side of a color set*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; paletteSize = 6;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;/*parent sprite container*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; palette:&lt;span style="color: rgb(51, 51, 255);"&gt;Sprite = new Sprite&lt;/span&gt;();&lt;br /&gt;palette.&lt;span style="color: rgb(51, 51, 255);"&gt;x &lt;/span&gt;= 10;&lt;br /&gt;palette.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt; = 45&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(palette);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;/*the square whose color is to be changed*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; colorSampler:&lt;span style="color: rgb(51, 51, 255);"&gt;Sprite = new Sprite&lt;/span&gt;();&lt;br /&gt;colorSampler.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.beginFill&lt;/span&gt;(0xFFFFFF);&lt;br /&gt;colorSampler.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.drawRect&lt;/span&gt;(280,80,100,100);&lt;br /&gt;colorSampler.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.endFill&lt;/span&gt;();&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(colorSampler);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;/*create the palette*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;for(var&lt;/span&gt; k=0;k&amp;lt;&lt;palettesize;k++) i="0;i&lt;paletteSize;i++)" j="0;j&lt;paletteSize;j++)" var="" sprite="new" x="(squareSize+1)*paletteSize*(k%3)+i*(squareSize+1);" y="(squareSize+1)*paletteSize*(Math.floor(k/3))+j*(squareSize+1);"&gt;&lt;span style=""&gt;paletteSize;k++)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;for(var&lt;/span&gt; i=0;i&lt;/span&gt;&lt;/palettesize;k++)&gt;&amp;lt;&lt;palettesize;k++) i="0;i&lt;paletteSize;i++)" j="0;j&lt;paletteSize;j++)" var="" sprite="new" x="(squareSize+1)*paletteSize*(k%3)+i*(squareSize+1);" y="(squareSize+1)*paletteSize*(Math.floor(k/3))+j*(squareSize+1);"&gt;&lt;span style=""&gt;paletteSize;i++)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;for(var&lt;/span&gt; j=0;j&lt;/span&gt;&lt;/palettesize;k++)&gt;&amp;lt;&lt;palettesize;k++) i="0;i&lt;paletteSize;i++)" j="0;j&lt;paletteSize;j++)" var="" sprite="new" x="(squareSize+1)*paletteSize*(k%3)+i*(squareSize+1);" y="(squareSize+1)*paletteSize*(Math.floor(k/3))+j*(squareSize+1);"&gt;&lt;span style=""&gt;paletteSize;j++)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; square:&lt;span style="color: rgb(51, 51, 255);"&gt;Sprite = new Sprite&lt;/span&gt;();&lt;br /&gt;            square.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.beginFill&lt;/span&gt;(0xFFFFFF);&lt;br /&gt;            square.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.drawRect&lt;/span&gt;(0,0,squareSize,squareSize);&lt;br /&gt;            square.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.endFill&lt;/span&gt;();&lt;br /&gt;            square.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt; = (squareSize+1)*paletteSize*(k%3)+i*(squareSize+1);&lt;br /&gt;            square.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt; = (squareSize+1)*paletteSize*(Math.floor(k/3))+j*(squareSize+1);&lt;br /&gt;            &lt;span style="color: rgb(102, 102, 102);"&gt;/*add a gradual color to each small square.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;              By this distribution, the palette will have 6&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;              color sets each made up of 6x6 small&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;              squares. In all of these color sets there will&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;              be an increasing amount of the GREEN mask along&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;              the horizontal direction, and the BLUE mask along&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;              the vertical direction. The red mask is distributed&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;              over these 6 sets.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;            */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; color:&lt;span style="color: rgb(51, 51, 255);"&gt;ColorTransform = new ColorTransform&lt;/span&gt;();&lt;br /&gt;           color.&lt;span style="color: rgb(51, 51, 255);"&gt;greenMultiplier&lt;/span&gt; = i/(paletteSize-1);&lt;br /&gt;           color.&lt;span style="color: rgb(51, 51, 255);"&gt;blueMultiplier&lt;/span&gt; = j/(paletteSize-1);&lt;br /&gt;           color.&lt;span style="color: rgb(51, 51, 255);"&gt;redMultiplier&lt;/span&gt; = k/(paletteSize-1);&lt;br /&gt;           square&lt;span style="color: rgb(51, 51, 255);"&gt;.transform.colorTransform&lt;/span&gt;=color;&lt;br /&gt;         &lt;br /&gt;           palette.&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(square);&lt;br /&gt;         &lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;/*listen for a click on the small square*/&lt;/span&gt;&lt;br /&gt;           square.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.CLICK&lt;/span&gt;,clickHandler);          &lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;/*change the color of the square*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  clickHandler(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;/*the color masks are actually found by processing&lt;br /&gt;   the position of the clicked small square*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; X=&lt;span style="color: rgb(51, 51, 255);"&gt;e.currentTarget.x&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; Y=&lt;span style="color: rgb(51, 51, 255);"&gt;e.currentTarget&lt;/span&gt;.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt;;&lt;br /&gt;   X=X/(squareSize+1);&lt;br /&gt;   Y=Y/(squareSize+1);&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; Z=&lt;span style="color: rgb(51, 51, 255);"&gt;Math.floor&lt;/span&gt;(X/paletteSize)+&lt;span style="color: rgb(51, 51, 255);"&gt;Math.floor&lt;/span&gt;(Y/paletteSize)*3;&lt;br /&gt;   X=X-&lt;span style="color: rgb(51, 51, 255);"&gt;Math.floor&lt;/span&gt;(X/paletteSize)*paletteSize;&lt;br /&gt;   Y=Y-&lt;span style="color: rgb(51, 51, 255);"&gt;Math.floor&lt;/span&gt;(Y/paletteSize)*paletteSize;&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;/*apply the new color*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; color:&lt;span style="color: rgb(51, 51, 255);"&gt;ColorTransform = new ColorTransform&lt;/span&gt;();&lt;br /&gt;   color.&lt;span style="color: rgb(51, 51, 255);"&gt;greenMultiplier&lt;/span&gt; =X/(paletteSize-1);&lt;br /&gt;   color.&lt;span style="color: rgb(51, 51, 255);"&gt;blueMultiplier &lt;/span&gt;=Y/(paletteSize-1);&lt;br /&gt;   color.&lt;span style="color: rgb(51, 51, 255);"&gt;redMultiplier&lt;/span&gt; = Z/(paletteSize-1);&lt;br /&gt;   colorSampler.&lt;span style="color: rgb(51, 51, 255);"&gt;transform.colorTransform&lt;/span&gt;=color;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Thats it!! Hit Ctrl+Enter to Test your movie.&lt;br /&gt;&lt;span style="color: rgb(204, 153, 51);"&gt;Change the code to make the palette more detailed and sensitive.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 153, 51);"&gt;Just like the color palette in Flash CS4, you can add a slider that darkens any given color. This can be achieved by gradually decreasing all the color masks simutaneously. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/palettesize;k++)&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-2724188001776870091?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/2724188001776870091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/imitate-flash-cs4-color-palette-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2724188001776870091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2724188001776870091'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/imitate-flash-cs4-color-palette-in.html' title='Imitate the Flash CS4 Color Palette in Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-5182641365313914511</id><published>2009-09-16T20:20:00.000+05:30</published><updated>2009-09-16T20:40:46.064+05:30</updated><title type='text'>Create a very Realistic, custom Class, Dynamic Smoke Effect in Actionscript 3</title><content type='html'>&lt;div align="middle"&gt;&lt;br /&gt; &lt;object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="smoke" align="middle" height="300" width="200"&gt;&lt;br /&gt; &lt;param name="allowScriptAccess" value="sameDomain"&gt;&lt;br /&gt; &lt;param name="allowFullScreen" value="false"&gt;&lt;br /&gt; &lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/refl/smoke.swf"&gt;&lt;br /&gt; &lt;param name="quality" value="high"&gt;&lt;br /&gt; &lt;param name="bgcolor" value="#000000"&gt; &lt;br /&gt; &lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/refl/smoke.swf" quality="high" bgcolor="#000000" name="smoke" align="middle" height="300" width="200"&gt;&lt;/embed&gt;&lt;br /&gt; &lt;/object&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In the root directory of the .fla file create a new folder and name it script. Now open your favourite text editor and copy and paste the following code&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*&lt;br /&gt;   *The smoke effect is achieved by creating small circles&lt;br /&gt;   *They are continuously moved upwards&lt;br /&gt;   *A BlurFilter is applied to make them look realistic&lt;br /&gt;   *As they float above their dimensions are increased and the alpha reduced&lt;br /&gt;   *Actually only 40 particles are present and they are continuosly&lt;br /&gt;       recycled to prevent the main memory occupied by the .swf file&lt;br /&gt;       from increasing.&lt;br /&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;package&lt;/span&gt;&lt;span style="font-style: italic;"&gt; script{&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;import flash.display.Sprite;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.display.Shape;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.display.MovieClip;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.events.Event;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.events.TimerEvent;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.filters.BlurFilter;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    import flash.utils.Timer;&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;public class&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Smoke&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; extends Sprite&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    {&lt;/span&gt;&lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*this will be the parent container*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; smoke_mc:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MovieClip = new MovieClip&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*color of the smoke*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; color:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;uint&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*radius of each smoke particle*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; partRadius:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 1;&lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*BlurFilter for the smoke particles*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; blur:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;BlurFilter = new BlurFilter&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(8,8,2);&lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*timer to attach smoke particles*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; timer:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Timer = new Timer&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(100);&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*&lt;br /&gt;           the constructor takes 3 parameters-&lt;br /&gt;           X and Y coordinates of the point of origination&lt;br /&gt;           and the color of the smoke&lt;br /&gt;       */&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;public function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Smoke(xc:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,yc:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,col:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;uint&lt;/span&gt;&lt;span style="font-style: italic;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        {&lt;/span&gt;&lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*attach the parent movieClip*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smoke_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=xc;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smoke_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=yc;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(smoke_mc);&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*assign the color*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            color=col;&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*start the timer*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            timer.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;start&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*listener for the timer. the function startSmoke&lt;br /&gt;               is called every 100 miliseconds*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            timer.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(TimerEvent.TIMER&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,startSmoke);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*attaches one smoke particle to the stage*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; startSmoke(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;TimerEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        {&lt;/span&gt;&lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*if 40 particles has been attached&lt;br /&gt;               stop attaching any more    */&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(smoke_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;numChildren&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&gt;40)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;                &lt;span style="font-style: italic;color:gray;" &gt;/*stop the timer*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                timer.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;stop&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;                &lt;span style="font-style: italic;color:gray;" &gt;/*remove the timer listener*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                timer.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;removeEventListener(TimerEvent.TIMER&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,startSmoke);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*atach a particle to the parent movieclip*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smoke_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(smokeParticle());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*Create and return a fully formed smoke particle*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; smokeParticle():&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Sprite&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            var smokePart:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Sprite&lt;/span&gt;&lt;span style="font-style: italic;"&gt; =&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; new Sprite&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smokePart.&lt;/span&gt;&lt;span style="color: rgb(51, 153, 153); font-style: italic;"&gt;graphics.beginFill&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(color);&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*create the particle at a random point&lt;br /&gt;           between +2 and -2 pixels from the given&lt;br /&gt;           X coordinate*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; randX = -2+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*4;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smokePart.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.drawCircle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(randX,0,partRadius);&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smokePart.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.endFill&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*blur the particle*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smokePart.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;filters&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=[blur];&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*add more randomness to the X coordinate*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; randDist = -10+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*20;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smokePart.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+=randDist;&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*move the particles*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            smokePart.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(Event.ENTER_FRAME&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,moveUp);&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;return&lt;/span&gt;&lt;span style="font-style: italic;"&gt; smokePart;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;           &lt;br /&gt;        &lt;span style="font-style: italic;color:gray;" &gt;/*&lt;br /&gt;           move and resize the particles&lt;br /&gt;           change the values to see their&lt;br /&gt;           effects on the smoke&lt;br /&gt;       */&lt;/span&gt;   &lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;private function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  moveUp(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        {&lt;/span&gt;&lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*if the particle is visible*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&gt;0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;                &lt;span style="font-style: italic;color:gray;" &gt;/*move it upwards*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-=1;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;                &lt;span style="font-style: italic;color:gray;" &gt;/*increase the width*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.width&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+=0.5;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;                &lt;span style="font-style: italic;color:gray;" &gt;/*incraese the height at a lesser rate*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.height&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+=0.3;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;                &lt;span style="font-style: italic;color:gray;" &gt;/*reduce the alpha*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-=.004;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;            &lt;span style="font-style: italic;color:gray;" &gt;/*if the particle is not visible&lt;br /&gt;               restore Y to 0 ,X to a random&lt;br /&gt;               value, width and height to the&lt;br /&gt;               original radius and the alpha to 1*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; randDist = -5+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+=randDist;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.width&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=partRadius;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.height&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=partRadius;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will be your custom class. Save this file in the folder named "script", with the name "Smoke.as". Now open&lt;br /&gt;&lt;br /&gt;your .fla file and hit Ctrl+J to bring up the Document Properties window and set the Width and Height to 200&lt;br /&gt;&lt;br /&gt;and 300 and the Background Color to 0x000000 (Black).&lt;br /&gt;Click on Ok and then select the first frame of the layer and hit F9. In the Actions window that pops up, Copy&lt;br /&gt;&lt;br /&gt;the following lines of code&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*import the custom class*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;import&lt;/span&gt;&lt;span style="font-style: italic;"&gt; script.Smoke;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*call the constructor to create a new instance of the Smoke class&lt;br /&gt;   change the X and Y coordinates and the Color of the smoke here.&lt;br /&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; smoke:Smoke=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Smoke(100,150,0xBBBBBB);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*add the instance to the stage*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(smoke);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Thats it. Hit Ctrl+Enter to test your movie.&lt;br /&gt;**&lt;br /&gt;Add Objects to your movie and create multiple instances with different colors for a more complicated effect&lt;br /&gt;&lt;br /&gt;Download the source files &lt;a href="http://www.fileden.com/files/2009/9/5/2565234/refl/smoke.zip"&gt; here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-5182641365313914511?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/5182641365313914511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-very-realistic-custom-class.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5182641365313914511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5182641365313914511'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-very-realistic-custom-class.html' title='Create a very Realistic, custom Class, Dynamic Smoke Effect in Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-1960269997288618428</id><published>2009-09-12T12:00:00.000+05:30</published><updated>2009-09-12T12:15:16.298+05:30</updated><title type='text'>Create a 3-D Image Reflection Effect with and advanced apllication of Bitmaps</title><content type='html'>&lt;div align="middle"&gt;&lt;br /&gt; &lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="reflection" align="middle" height="500" width="350"&gt;&lt;br /&gt; &lt;param name="allowScriptAccess" value="sameDomain"&gt;&lt;br /&gt; &lt;param name="allowFullScreen" value="false"&gt;&lt;br /&gt; &lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/refl/reflection.swf"&gt;&lt;param name="quality" value="high"&gt;&lt;param name="bgcolor" value="#000000"&gt; &lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/refl/reflection.swf" quality="high" bgcolor="#000000" name="reflection" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" align="middle" height="500" width="350"&gt;&lt;/embed&gt;&lt;br /&gt; &lt;/object&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This tutorial is insprired by the one i saw &lt;a href="http://www.flashandmath.com/howtos/reflection3d/index.html"&gt;here&lt;/a&gt; but my application is actually different. I will use flters instead of masks&lt;br /&gt;The 3-D effect is achieved with the application of the flash.display.BitmapData class and various Filters.&lt;br /&gt;&lt;br /&gt;First we import an image on to the libray Through File-&gt;Import-&gt;Import to Library.. .here I am using a 200x200 album cover of Flipsyde's first album "We the People".&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SqtDLKkHs5I/AAAAAAAAAXA/9P0YprON9W4/s1600-h/cover.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 200px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SqtDLKkHs5I/AAAAAAAAAXA/9P0YprON9W4/s400/cover.JPG" alt="" id="BLOGGER_PHOTO_ID_5380468038917665682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now go to the library and right click on the image and select Properties. In the Linkage properties select Export For Actionscript and set the class name as pic;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SqtDJ6k5XmI/AAAAAAAAAWo/XfzNP_0djSU/s1600-h/1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 379px; height: 157px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SqtDJ6k5XmI/AAAAAAAAAWo/XfzNP_0djSU/s400/1.bmp" alt="" id="BLOGGER_PHOTO_ID_5380468017446084194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Create a new movieclip to rotate your image and its reflection. Mine looks like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SqtDKH0QzmI/AAAAAAAAAWw/Wmg55VKydVU/s1600-h/2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 124px; height: 47px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SqtDKH0QzmI/AAAAAAAAAWw/Wmg55VKydVU/s400/2.bmp" alt="" id="BLOGGER_PHOTO_ID_5380468021000195682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Drag two instances of this on to the stage and rotate one to point to the right. give them instance names "l_mc" and "r_mc".&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SqtDKfS_EZI/AAAAAAAAAW4/9mXtLMyJ1f4/s1600-h/3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 188px; height: 63px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SqtDKfS_EZI/AAAAAAAAAW4/9mXtLMyJ1f4/s400/3.bmp" alt="" id="BLOGGER_PHOTO_ID_5380468027303072146" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;That done select the first frame of the Layer and copy and paste the following code&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*image dimensions*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; imageHt=200;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; imageWd=200;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*indicates the magnitude of rotation*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; rot=0;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*flags the direction of rotation*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; goLeft:&lt;span style="color: rgb(51, 51, 255);"&gt;Boolean&lt;/span&gt; =&lt;span style="color: rgb(51, 51, 255);"&gt; false&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; goRight:&lt;span style="color: rgb(51, 51, 255);"&gt;Boolean&lt;/span&gt; =&lt;span style="color: rgb(51, 51, 255);"&gt; false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/**load the image from the library into a bitmap data*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; bitmap:&lt;span style="color: rgb(51, 51, 255);"&gt;BitmapData&lt;/span&gt;=&lt;span style="color: rgb(51, 51, 255);"&gt;new&lt;/span&gt; pic(imageHt,imageWd);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*declare the container Sprites. "actual" will hold the image&lt;br /&gt;"reflection" will hold the reflection and "container" will&lt;br /&gt;hold these two*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; container:&lt;span style="color: rgb(51, 51, 255);"&gt;Sprite&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new Sprite&lt;/span&gt;();&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; actual:&lt;span style="color: rgb(51, 51, 255);"&gt;Sprite&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new Sprite&lt;/span&gt;();&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; reflection:&lt;span style="color: rgb(51, 51, 255);"&gt;Sprite&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new Sprite&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*load the bitmap data into two bitmaps to&lt;br /&gt;display the image and its reflection resp.*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; imgage:&lt;span style="color: rgb(51, 51, 255);"&gt;Bitmap&lt;/span&gt;= &lt;span style="color: rgb(51, 51, 255);"&gt;new Bitmap&lt;/span&gt;(bitmap);&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; refl:&lt;span style="color: rgb(51, 51, 255);"&gt;Bitmap&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new Bitmap&lt;/span&gt;(bitmap);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*&lt;br /&gt;Filters for the reflection. the parameters are&lt;br /&gt;Blur Filter - (blurX,blurY,quality).&lt;br /&gt;Bevel Filter  - (distance, angle, highlight color,highlight alpha,&lt;br /&gt;                    shadow color,shadow alpha,blurX,blurY,quality,&lt;br /&gt;                    strength,type).&lt;br /&gt;notice the filter is applied just to the container bitmap,&lt;br /&gt;not the bitmap data itself.&lt;br /&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; _blur:&lt;span style="color: rgb(51, 51, 255);"&gt;BlurFilter&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new BlurFilter&lt;/span&gt;(3,3,1);&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; _bevel:&lt;span style="color: rgb(51, 51, 255);"&gt;BevelFilter&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new BevelFilter&lt;/span&gt;(50,90,0x000000,1,0x003366,.2,1,70,1,1,&lt;span style="color: rgb(0, 153, 0);"&gt;"inner"&lt;/span&gt;);&lt;br /&gt;refl.&lt;span style="color: rgb(51, 51, 255);"&gt;filters&lt;/span&gt;=[_blur,_bevel];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*attach the image to the top Sprite container*/&lt;/span&gt;&lt;br /&gt;actual.&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(imgage);&lt;br /&gt;actual.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt; = -imageHt/2;&lt;br /&gt;actual.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt; = 0;&lt;br /&gt;container.&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(actual);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*flip the reflection along the X axis and attach&lt;br /&gt;    the image to the top Sprite container*/&lt;/span&gt;&lt;br /&gt;reflection.&lt;span style="color: rgb(51, 51, 255);"&gt;rotationX&lt;/span&gt; = 180;&lt;br /&gt;reflection.&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(refl);&lt;br /&gt;reflection.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt; = -imageHt/2;&lt;br /&gt;reflection.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt; = 2*imageWd+1;&lt;br /&gt;container.&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(reflection);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*attach the top level container to the stage*/&lt;/span&gt;&lt;br /&gt;container.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt;=175;&lt;br /&gt;container.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt; = 40;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(container);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*this creates an improved rotational effect.&lt;br /&gt;change the value of pp.fieldOfView to see&lt;br /&gt;what happens*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; pp:&lt;span style="color: rgb(51, 51, 255);"&gt;PerspectiveProjection=new PerspectiveProjection&lt;/span&gt;();&lt;br /&gt;pp.&lt;span style="color: rgb(51, 51, 255);"&gt;fieldOfView&lt;/span&gt;=15;&lt;br /&gt;container.&lt;span style="color: rgb(51, 51, 255);"&gt;transform.perspectiveProjection&lt;/span&gt;=pp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*add listeners*/&lt;/span&gt;&lt;br /&gt;addEventListener(Event.ENTER_FRAME,rotate)&lt;br /&gt;l_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.MOUSE_OVER&lt;/span&gt;,rotLeft);&lt;br /&gt;r_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.MOUSE_OVER&lt;/span&gt;,rotRight);&lt;br /&gt;&lt;br /&gt;l_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.MOUSE_OUT&lt;/span&gt;,stopLeft);&lt;br /&gt;r_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.MOUSE_OVER&lt;/span&gt;,stopRight);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*start left rotation*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt; rotLeft(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;goLeft=true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*start right rotation*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt; rotRight(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;goRight=true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*stop left rotation*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  stopLeft(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;goLeft=false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*stop right rotation*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  stopRight(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;goRight=false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*rotate by the given amount*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  rotate(e:&lt;span style="color: rgb(51, 51, 255);"&gt;Event&lt;/span&gt;) {&lt;br /&gt;container.&lt;span style="color: rgb(51, 51, 255);"&gt;rotationY&lt;/span&gt;=rot;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;if&lt;/span&gt;(goLeft)&lt;br /&gt;    rot+=4;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;else if&lt;/span&gt;(goRight)&lt;br /&gt;    rot-=4;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Hit &lt;span style="font-weight: bold;"&gt;Ctrl+Enter&lt;/span&gt; to test your movie. Change the background to suit your visual needs.&lt;br /&gt;&lt;br /&gt;Download the .fla file &lt;a href="http://www.fileden.com/files/2009/9/5/2565234/refl/reflection.zip"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Enjoy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-1960269997288618428?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/1960269997288618428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-3-d-image-reflection-effect-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/1960269997288618428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/1960269997288618428'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-3-d-image-reflection-effect-with.html' title='Create a 3-D Image Reflection Effect with and advanced apllication of Bitmaps'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_s6gSPX95als/SqtDLKkHs5I/AAAAAAAAAXA/9P0YprON9W4/s72-c/cover.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-2412921756818100575</id><published>2009-09-10T21:12:00.000+05:30</published><updated>2009-09-12T12:26:08.526+05:30</updated><title type='text'>Create a Funky Menu</title><content type='html'>&lt;div align="middle"&gt;&lt;br /&gt;&lt;object id="menu" align="middle" height="150" width="450"&gt;&lt;br /&gt;&lt;param name="allowScriptAccess" value="sameDomain"&gt;&lt;br /&gt;&lt;param name="allowFullScreen" value="false"&gt;&lt;br /&gt;&lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/refl/menu.swf"&gt;&lt;br /&gt;&lt;param name="quality" value="high"&gt;&lt;br /&gt;&lt;param name="bgcolor" value="#000000"&gt;&lt;br /&gt;&lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/refl/menu.swf" quality="high" bgcolor="#000000" name="menu" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" align="middle" height="150" width="450"&gt;&lt;/embed&gt;&lt;br /&gt;&lt;/object&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will create a nice menu with an advanced mouseOver handler for the buttons.&lt;br /&gt;&lt;br /&gt;This tutorial is actually inspired by the pretty cool one I saw&lt;br /&gt;&lt;a href="http://tutorials.flashmymind.com/2009/05/shaky-flash-menu-with-actionscript-3/"&gt;here&lt;/a&gt;&lt;br /&gt;But there the person used a special pre-scripted class called "TweenMax". I will try to do it with my own custom class. The animation is a little different because I haven't used the Tween Class at all.&lt;br /&gt;&lt;br /&gt;To begin create a New Folder in your .fla root directory and name it "script". Inside it create a file with the name "menuButton.as". Copy and paste the follwing code in it. This will give you the custom class&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; package&lt;/span&gt; script{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;import flash.display.Sprite;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.display.Shape;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.display.MovieClip;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.display.DisplayObject;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.text.TextField;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.text.TextFormat;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.text.TextFieldAutoSize;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.events.MouseEvent;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.events.TimerEvent;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.geom.ColorTransform ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            import flash.utils.Timer;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;public class&lt;/span&gt; menuButton &lt;span style="color: rgb(51, 51, 255);"&gt;extends Sprite&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*the parent movie clip*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;private var&lt;/span&gt; button:&lt;span style="color: rgb(51, 51, 255);"&gt;MovieClip&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new MovieClip&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*name of the button*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255);"&gt; private var&lt;/span&gt; buttonName:&lt;span style="color: rgb(51, 51, 255);"&gt;String&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*X coordinate of the button*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255);"&gt; private var&lt;/span&gt; X:&lt;span style="color: rgb(51, 51, 255);"&gt;Number&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*X coordinate of the button*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255);"&gt; private var&lt;/span&gt; Y:&lt;span style="color: rgb(51, 51, 255);"&gt;Number&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*text field to display the name*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;private var&lt;/span&gt; buttonText_txt:&lt;span style="color: rgb(51, 51, 255);"&gt;TextField=new TextField&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*timer to monitor the random movements*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255);"&gt; private var&lt;/span&gt; timer:&lt;span style="color: rgb(51, 51, 255);"&gt;Timer&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new Timer&lt;/span&gt;(100);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*the constructor takes 3 parameters,the button&lt;br /&gt;            name and the x and y coordinates */&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;public function&lt;/span&gt;  menuButton(str:&lt;span style="color: rgb(51, 51, 255);"&gt;String&lt;/span&gt;, xc:&lt;span style="color: rgb(51, 51, 255);"&gt;Number&lt;/span&gt;, yc:&lt;span style="color: rgb(51, 51, 255);"&gt;Number&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            buttonName=str;&lt;br /&gt;            X=xc;&lt;br /&gt;            Y=yc;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*create the button*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255);"&gt; public function&lt;/span&gt;  getButton()&lt;br /&gt;        {   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*assign x and y coordinates*/&lt;/span&gt;&lt;br /&gt;            button.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt; = X;&lt;br /&gt;            button.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt; = Y;&lt;br /&gt;   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*create the background of a 8x4 array of&lt;br /&gt;            small squares*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; i=0;i&amp;lt;4;i++)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255);"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; j=0;j&amp;lt;8;j++)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; rect:&lt;span style="color: rgb(51, 51, 255);"&gt;Sprite = new Sprite&lt;/span&gt;();&lt;br /&gt;                    rect.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.beginFill&lt;/span&gt;(0x896434);&lt;br /&gt;                    rect.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.drawRect&lt;/span&gt;(j*9,i*9,8,8);&lt;br /&gt;                    rect.&lt;span style="color: rgb(51, 51, 255);"&gt;graphics.endFill&lt;/span&gt;();&lt;br /&gt;                    button.&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(rect);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*format in which to display the name*/&lt;/span&gt;&lt;br /&gt;            var format:&lt;span style="color: rgb(51, 51, 255);"&gt;TextFormat&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new TextFormat&lt;/span&gt;();&lt;br /&gt;            format&lt;span style="color: rgb(51, 51, 255);"&gt;.font &lt;/span&gt;= &lt;span style="color: rgb(0, 153, 0);"&gt;"verdana"&lt;/span&gt;;&lt;br /&gt;            format.&lt;span style="color: rgb(51, 51, 255);"&gt;color&lt;/span&gt; = 0xFFFFFF;&lt;br /&gt;            format.&lt;span style="color: rgb(51, 51, 255);"&gt;size&lt;/span&gt; = 18;&lt;br /&gt;   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*create the text field and display the&lt;br /&gt;                button name*/&lt;/span&gt;&lt;br /&gt;            buttonText_txt.&lt;span style="color: rgb(51, 51, 255);"&gt;selectable&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;false&lt;/span&gt;;&lt;br /&gt;            buttonText_txt.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt;=2;&lt;br /&gt;            buttonText_txt.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt;=5;&lt;br /&gt;            buttonText_txt.&lt;span style="color: rgb(51, 51, 255);"&gt;text&lt;/span&gt; = buttonName;&lt;br /&gt;            buttonText_txt.&lt;span style="color: rgb(51, 51, 255);"&gt;setTextFormat&lt;/span&gt;(format);&lt;br /&gt;            buttonText_txt.&lt;span style="color: rgb(51, 51, 255);"&gt;autoSize = TextFieldAutoSize.LEFT&lt;/span&gt;;&lt;br /&gt;            button.&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(buttonText_txt);&lt;br /&gt;   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*attach the button to the stage*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(button);&lt;br /&gt;   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*create mouse listeners*/&lt;/span&gt;&lt;br /&gt;            button.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.MOUSE_OVER&lt;/span&gt;,mouseOverHandler);&lt;br /&gt;            button.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.MOUSE_OUT&lt;/span&gt;,mouseOutHandler);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255);"&gt; private function&lt;/span&gt;  mouseOverHandler(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;            &lt;span style="color:gray;"&gt;/*start the timer to start the random&lt;br /&gt;            movement of the background squares*/&lt;/span&gt;&lt;br /&gt;            timer.&lt;span style="color: rgb(51, 51, 255);"&gt;start&lt;/span&gt;();&lt;br /&gt;            timer.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(TimerEvent.TIMER&lt;/span&gt;,moveRandom);&lt;br /&gt;   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*loop through each of the small squares&lt;br /&gt;            set it to a random color and an alpha of 0.6*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; i=0;i&amp;lt;button.&lt;span style="color: rgb(51, 51, 255);"&gt;numChildren&lt;/span&gt;-1;i++)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; obj:&lt;span style="color: rgb(51, 51, 255);"&gt;Object&lt;/span&gt; = button.&lt;span style="color: rgb(51, 51, 255);"&gt;getChildAt&lt;/span&gt;(i);&lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; color:&lt;span style="color: rgb(51, 51, 255);"&gt;ColorTransform &lt;/span&gt;= obj.&lt;span style="color: rgb(51, 51, 255);"&gt;transform.colorTransform&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; randx = -30+&lt;span style="color: rgb(51, 51, 255);"&gt;Math.random&lt;/span&gt;()*60;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; randy = -30+&lt;span style="color: rgb(51, 51, 255);"&gt;Math.random&lt;/span&gt;()*60;&lt;br /&gt;obj.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt;=randx;&lt;br /&gt;obj.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt;=randy;&lt;br /&gt;                color.&lt;span style="color: rgb(51, 51, 255);"&gt;color&lt;/span&gt;=0x00000;&lt;br /&gt;                &lt;span style="color:gray;"&gt;/*multiplying by 2 gives brighter colors*/&lt;/span&gt;&lt;br /&gt;                color.&lt;span style="color: rgb(51, 51, 255);"&gt;redMultiplier&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;Math.random&lt;/span&gt;()*2;&lt;br /&gt;                color.&lt;span style="color: rgb(51, 51, 255);"&gt;blueMultiplier&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;Math.random&lt;/span&gt;()*2;&lt;br /&gt;                color.&lt;span style="color: rgb(51, 51, 255);"&gt;greenMultiplier&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;Math.random&lt;/span&gt;()*2;&lt;br /&gt;                obj.&lt;span style="color: rgb(51, 51, 255);"&gt;transform.colorTransform&lt;/span&gt; = color;&lt;br /&gt;                obj.&lt;span style="color: rgb(51, 51, 255);"&gt;alpha&lt;/span&gt; =0.6;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255);"&gt; private function&lt;/span&gt;  mouseOutHandler(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;            &lt;span style="color:gray;"&gt;/*stop the timer and the random movements*/&lt;/span&gt;&lt;br /&gt;            timer.&lt;span style="color: rgb(51, 51, 255);"&gt;stop&lt;/span&gt;();&lt;br /&gt;   &lt;br /&gt;            &lt;span style="color:gray;"&gt;/*restore previous values of x and y coordinates&lt;br /&gt;            and the color*/&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; i=0;i&amp;lt;button.&lt;span style="color: rgb(51, 51, 255);"&gt;numChildren&lt;/span&gt;-1;i++)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; obj:&lt;span style="color: rgb(51, 51, 255);"&gt;Object&lt;/span&gt; = button&lt;span style="color: rgb(51, 51, 255);"&gt;.getChildAt&lt;/span&gt;(i);&lt;br /&gt;               &lt;span style="color: rgb(51, 51, 255);"&gt; var&lt;/span&gt; color:&lt;span style="color: rgb(51, 51, 255);"&gt;ColorTransform&lt;/span&gt; = obj.&lt;span style="color: rgb(51, 51, 255);"&gt;transform.colorTransform&lt;/span&gt;;&lt;br /&gt;                color.&lt;span style="color: rgb(51, 51, 255);"&gt;color&lt;/span&gt;=0x896434;&lt;br /&gt;                obj&lt;span style="color: rgb(51, 51, 255);"&gt;.transform.colorTransform&lt;/span&gt; = color;&lt;br /&gt;obj.&lt;span style="color: rgb(51, 51, 255);"&gt;x = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Math.floor&lt;/span&gt;((i%8)/9);&lt;br /&gt;obj.&lt;span style="color: rgb(51, 51, 255);"&gt;y = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Math.floor(Math.floor&lt;/span&gt;(i/8)/9);&lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255);"&gt;alpha&lt;/span&gt; = 1;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:gray;"&gt;/*move the background squares randomly*/&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;private function&lt;/span&gt;  moveRandom(e:&lt;span style="color: rgb(51, 51, 255);"&gt;TimerEvent&lt;/span&gt;) {&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255);"&gt; for&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; i=0;i&amp;lt;button.&lt;span style="color: rgb(51, 51, 255);"&gt;numChildren&lt;/span&gt;-1;i++)&lt;br /&gt;            {&lt;br /&gt;                var obj:&lt;span style="color: rgb(51, 51, 255);"&gt;Object &lt;/span&gt;= button.&lt;span style="color: rgb(51, 51, 255);"&gt;getChildAt&lt;/span&gt;(i);&lt;br /&gt;       &lt;br /&gt;                &lt;span style="color:gray;"&gt;/*find random values for x and y coordinates*/&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; randx = -1+&lt;span style="color: rgb(51, 51, 255);"&gt;Math.random&lt;/span&gt;()*2;&lt;br /&gt;                &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; randy = -1+&lt;span style="color: rgb(51, 51, 255);"&gt;Math.random&lt;/span&gt;()*2;&lt;br /&gt;       &lt;br /&gt;                &lt;span style="color:gray;"&gt;/*assign the random coordinates*/&lt;/span&gt;&lt;br /&gt;                obj.&lt;span style="color: rgb(51, 51, 255);"&gt;x&lt;/span&gt;-=randx;&lt;br /&gt;                obj.&lt;span style="color: rgb(51, 51, 255);"&gt;y&lt;/span&gt;-=randy;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now open your .fla file and hit Ctrl+J to bring up the Document Properties window.Change the height to 150 and the background color to 0x00000.&lt;br /&gt;That done, select the first frame and hit F9. Copy and paste the following script&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*import the custom class*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;import &lt;/span&gt;script.menuButton;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*this array will contain the names of all the buttons you want in your menu*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; labels:&lt;span style="color: rgb(51, 51, 255);"&gt;Array&lt;/span&gt;=[&lt;span style="color: rgb(0, 153, 0);"&gt;"Home","Gallery","Login","Submit"&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*display the buttons*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; i=0;i&amp;lt;labels.&lt;span style="color: rgb(51, 51, 255);"&gt;length&lt;/span&gt;;i++)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; b:menuButton =&lt;span style="color: rgb(51, 51, 255);"&gt; new&lt;/span&gt; menuButton(labels[i],100*(i+1),60);&lt;br /&gt;b.getButton();&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;addChild&lt;/span&gt;(b);&lt;br /&gt;}    &lt;br /&gt;&lt;br /&gt;Hit Ctrl+Enter to test your movie!&lt;br /&gt;&lt;br /&gt;Download the &lt;a href="http://www.fileden.com/files/2009/9/5/2565234/refl/shakyMenu.zip"&gt;.fla file&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-2412921756818100575?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/2412921756818100575/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-funky-menu.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2412921756818100575'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2412921756818100575'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-funky-menu.html' title='Create a Funky Menu'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-2172429470727136915</id><published>2009-09-09T17:31:00.000+05:30</published><updated>2009-09-09T18:03:38.915+05:30</updated><title type='text'>Create a XML Driven, dynamic Word Jumble Puzzle</title><content type='html'>&lt;div align="middle"&gt;&lt;br /&gt;&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="jumble" align="middle" height="200" width="200"&gt;&lt;br /&gt; &lt;param name="allowScriptAccess" value="sameDomain"&gt;&lt;br /&gt; &lt;param name="allowFullScreen" value="false"&gt;&lt;br /&gt; &lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/jumble-post.swf"&gt;&lt;param name="quality" value="high"&gt;&lt;param name="bgcolor" value="#99cc99"&gt; &lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/jumble-post.swf" quality="high" bgcolor="#99cc99" name="jumble" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" align="middle" height="200" width="200"&gt;&lt;/embed&gt;&lt;br /&gt; &lt;/object&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;We will make a game where the player has to unjumble a given jumbled word. The words will be stored in an external XML file so that words can be easily changed and/or added.&lt;br /&gt;&lt;br /&gt;First we create the XML file. open your favourite text editor and copy in the following.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;gamedata&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;raffle&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;elephant&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;diamond&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;centre&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;giraffe&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;papyrus&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;dominate&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;raccoon&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;lizard&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;monitor&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;country&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;forest&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;bottle&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;carton&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;transfer&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;calendar&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;cricket&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;football&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;spoken&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;terminate&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;trailer&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;acoustic&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;bubble&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;yellow&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;national&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;language&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;word&amp;gt;shampoo&amp;lt;/word&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/gamedata&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Save it as words.xml and then open your new .fla file. Remeber the .swf and .xml files should be in the same directory.&lt;br /&gt;&lt;br /&gt;Hit Ctrl+J and bring up the Document Properties window and set the hieght and width to 200 and the background color to #99CC99.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sqea2OBRdJI/AAAAAAAAAWI/lFWp6Fl9AY8/s1600-h/1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 165px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sqea2OBRdJI/AAAAAAAAAWI/lFWp6Fl9AY8/s400/1.bmp" alt="" id="BLOGGER_PHOTO_ID_5379438536184394898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now select the Text Tool and draw a Dynamic text field. Go to the Propertoes Window and make sure the "Show Border around Text" and "Selectable" are not selected.Go to the Propertes window and type in its instance name as "jumble_txt" Now draw an Input text field with the "Show Border around Text" selected.This time its instance name will be "input_txt".Your Stage should look like this.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Sqea1pWiO6I/AAAAAAAAAWA/8lGDlLVwBco/s1600-h/2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 202px; height: 201px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Sqea1pWiO6I/AAAAAAAAAWA/8lGDlLVwBco/s400/2.bmp" alt="" id="BLOGGER_PHOTO_ID_5379438526341462946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;With the Text tool selected, draw two Static text boxes as label for the above fields, like so&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Sqea1QWW4FI/AAAAAAAAAV4/SrFZ2vZjssA/s1600-h/3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 204px; height: 200px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Sqea1QWW4FI/AAAAAAAAAV4/SrFZ2vZjssA/s400/3.bmp" alt="" id="BLOGGER_PHOTO_ID_5379438519629832274" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now hit Ctrl+F8 to bring up the New Symbol Window, change the name to "checker" and click OK. Draw you own button. Mine looks like this&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Sqea07aw5KI/AAAAAAAAAVw/TKH0PA6bTGw/s1600-h/4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 68px; height: 40px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Sqea07aw5KI/AAAAAAAAAVw/TKH0PA6bTGw/s400/4.bmp" alt="" id="BLOGGER_PHOTO_ID_5379438514011169954" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Similarly draw another button. Name it "next"&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Sqea0uvq8cI/AAAAAAAAAVo/b2wrsM2-byc/s1600-h/5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 60px; height: 40px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Sqea0uvq8cI/AAAAAAAAAVo/b2wrsM2-byc/s400/5.bmp" alt="" id="BLOGGER_PHOTO_ID_5379438510609199554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now go to the main stage and drag the two buttons onto the stage.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SqebOSzQa4I/AAAAAAAAAWY/ee6iQcSdcrY/s1600-h/6.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 202px; height: 205px;" src="http://3.bp.blogspot.com/_s6gSPX95als/SqebOSzQa4I/AAAAAAAAAWY/ee6iQcSdcrY/s400/6.bmp" alt="" id="BLOGGER_PHOTO_ID_5379438949784644482" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The instance name of the "checker" button should be check_mc and the other should be "next_mc"&lt;br /&gt;&lt;br /&gt;That done Create a new layer and name it Actions. Select the first frame and hit F9. Copy and paste the following code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; xmlLoader:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;URLLoader&lt;/span&gt;&lt;span style="font-style: italic;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new URLLoader&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*load the xml file*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;xmlLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;load(new URLRequest&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"words.xml"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*on completion of loading invoke the "parseXML" function*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;xmlLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(Event.COMPLETE&lt;/span&gt;&lt;span style="font-style: italic;"&gt;, parseXML);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;var words:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Array&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Array&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; parseXML(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;void&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i,j;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; menuLength;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*length of the word array*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; XMLData:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;XML&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new XML&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(xmlLoader.data);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;menuLength = XMLData.word.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;length&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*populate the globally defined array*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (i=0; i&amp;lt;len;i++)&lt;len;i++)&gt;&lt;menulength;&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        words[i]=XMLData.word[i];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*show the jumbled word*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    showWord();&lt;/span&gt;&lt;menulength;&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; actualWord;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*the word being displayed in unjumbled form*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; input;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*input typed in by the player*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*listen for mouse click*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;check_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.CLICK&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,checkAnswer);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;next_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;CLICK&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,newWord);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*show a jumbled word to solve*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  showWord() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*choose a random index of the words array&lt;br /&gt;and choose the word.Thus we choose a random&lt;br /&gt;word everytime*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; randChoice = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int(Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*words.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;length&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;actualWord = words[randChoice];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*display the jumbled word from the random array index*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;jumble_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text &lt;/span&gt;&lt;span style="font-style: italic;"&gt;= jumbled(actualWord);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;jumble_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;autoSize&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;TextFieldAutoSize.LEFT&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*show the button if hidden*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;check_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;visible&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=true;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*receive a string and return it after random jumbling*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  jumbled(word:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; len=word.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;length&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; rand;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; c;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; wordArray:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Array&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Array&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; jumbledWord:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new String&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color:gray;"&gt;/*convert the string to an array to avail &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;     &lt;span style="color: rgb(102, 102, 102);"&gt;b&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;etter indexed access*/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i=0;i&amp;lt;len;i++)&lt;len;i++)&gt;&lt;len;i++)&gt;&lt;len;i++)&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        wordArray[i]=word.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;charAt&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*randomise the array. The algorithm  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;sequentually picks a letter and swaps it&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;        with a random letter coming after it */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i=0;i&amp;lt;len;i++)&lt;len;i++)&gt;&lt;len;i++)&gt;&lt;len;i++)&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        rand = i+&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Math.random&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()*(len-i));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        c=wordArray[i];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        wordArray[i]=wordArray[rand];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        wordArray[rand]=c;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*reconvert array to string*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i=0;i &amp;lt;len;i++)&lt;/span&gt;&lt;/menulength;&gt;&lt;/menulength;&gt;&lt;/len;i++)&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        jumbledWord+=wordArray[i];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*return the jumbled string*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;return&lt;/span&gt;&lt;span style="font-style: italic;"&gt; jumbledWord;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;len;i++)&gt;&lt;len;i++) rand="i+int" c="wordArray[i];"&gt;&lt;len;i++)&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*trim whitespaces from the given string*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  trim(word:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*remove from front*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;word = word.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;replac&lt;/span&gt;&lt;span style="font-style: italic;"&gt;e( &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;/^\s*/&lt;/span&gt;&lt;span style="font-style: italic;"&gt;g,&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt; "" &lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*remove from end*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;word = word.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;replace&lt;/span&gt;&lt;span style="font-style: italic;"&gt;( &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;/\s*$/&lt;/span&gt;&lt;span style="font-style: italic;"&gt;g, &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;""&lt;/span&gt;&lt;span style="font-style: italic;"&gt; );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;return&lt;/span&gt;&lt;span style="font-style: italic;"&gt; word&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*check the answer typed in by the player*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;f&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;unction&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  checkAnswer(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;input=input_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*remove any whitespaces entered*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;input = trim(input);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*remove anything typed in by the user*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;input_txt&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;.text&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;""&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*hide the clicked button*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;check_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;visible&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*input is correct*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(input==actualWord)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;jumble_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = actualWord+&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;" :-))"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;else&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if input is wrong*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;jumble_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = actualWord+&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;" :-(("&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*show a new word*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  newWord(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;showWord();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hit &lt;span style="font-weight: bold;"&gt;Ctrl+Enter&lt;/span&gt; to test your movie!&lt;br /&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SqebN_qXeRI/AAAAAAAAAWQ/jndsIFBzGEM/s1600-h/7.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 202px; height: 203px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SqebN_qXeRI/AAAAAAAAAWQ/jndsIFBzGEM/s400/7.bmp" alt="" id="BLOGGER_PHOTO_ID_5379438944647084306" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;menulength;&gt;&lt;len;i++)&gt;&lt;len;i++) rand="i+int" c="wordArray[i];"&gt;&lt;len;i++)&gt;&lt;br /&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;/len;i++)&gt;&lt;/menulength;&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-2172429470727136915?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/2172429470727136915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-xml-driven-dynamic-word-jumble.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2172429470727136915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2172429470727136915'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-xml-driven-dynamic-word-jumble.html' title='Create a XML Driven, dynamic Word Jumble Puzzle'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_s6gSPX95als/Sqea2OBRdJI/AAAAAAAAAWI/lFWp6Fl9AY8/s72-c/1.bmp' height='72' width='72'/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-1287457934201906152</id><published>2009-09-08T08:13:00.001+05:30</published><updated>2009-10-08T22:17:06.240+05:30</updated><title type='text'>Create a Magnifying Glass Effect in Actionscript 3</title><content type='html'>&lt;object align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" height="400" id="magnifier" width="400"&gt;  &lt;param name="allowScriptAccess" value="sameDomain"&gt; &lt;param name="allowFullScreen" value="false"&gt; &lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/magnifier.swf"&gt;&lt;param name="quality" value="high"&gt;&lt;param name="bgcolor" value="#ffffff"&gt; &lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/magnifier.swf" quality="high" bgcolor="#ffffff" name="magnifier" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" align="middle" height="400" width="400"&gt;&lt;/embed&gt;  &lt;/object&gt; &lt;br /&gt;&lt;br /&gt;Hit Ctrl+J to bring up the Document Properties Window and set the width and the Height to 400. &lt;br /&gt;&lt;br /&gt;1. First we will draw the magnifying glass. Hit&lt;b&gt;Ctrl+F8&lt;/b&gt; to bring up the New Symbol window and give the name as magnifier. Click OK and draw a 100x100 cirlcle with fill color #009999 and alpha 20 and the stroke color as #663300. Set the stroke thickness as 5 pixels. Make sure you centre it. &lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_s6gSPX95als/SqXIWTWcTgI/AAAAAAAAAUY/2C4JviYScNc/s1600-h/b1_1.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378925615441006082" src="http://1.bp.blogspot.com/_s6gSPX95als/SqXIWTWcTgI/AAAAAAAAAUY/2C4JviYScNc/s400/b1_1.bmp" style="cursor: pointer; display: block; height: 151px; margin: 0px auto 10px; text-align: center; width: 179px;" /&gt;&lt;/a&gt; &lt;br /&gt;Now with The rectangle tool selected, fill color of #663300 and no stroke color draw a rectangle. This will be your glass's handle. Now select the Free Transform Tool and rotate it through 45 degrees &lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_s6gSPX95als/SqXIW8YL9ZI/AAAAAAAAAUg/qvbqmtQr4Wo/s1600-h/b1_2.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378925626454177170" src="http://2.bp.blogspot.com/_s6gSPX95als/SqXIW8YL9ZI/AAAAAAAAAUg/qvbqmtQr4Wo/s400/b1_2.bmp" style="cursor: pointer; display: block; height: 206px; margin: 0px auto 10px; text-align: center; width: 221px;" /&gt;&lt;/a&gt; &lt;br /&gt;now attach both the figures and your magnifying glass is done. &lt;br /&gt;&lt;br /&gt;2. Now we need the object to be magnified. Now remember we will not be actually magnifying anything. This will be an illusion. So we need the magnified object as well. I will using a 400x400 image of the album cover of Foo Fighter's "Skin and Bones". &lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_s6gSPX95als/SqXIXMSg0KI/AAAAAAAAAUo/TZEz0yDaPFY/s1600-h/FooF.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378925630725345442" src="http://4.bp.blogspot.com/_s6gSPX95als/SqXIXMSg0KI/AAAAAAAAAUo/TZEz0yDaPFY/s400/FooF.jpg" style="cursor: pointer; display: block; height: 400px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt; &lt;br /&gt;Go to File-&amp;gt;Import-&amp;gt;Import to Library..  and import the image into the library. Hit&lt;b&gt;Ctrl+F8&lt;/b&gt; to bring up the New Symbol window and type in the name as magnified. Drag the album cover from the library and centre it. &lt;br /&gt;Create a new symbol again and this time the name is original. Drag the image from the library as before but this time go to the properties panel and set the width and height to 150. centre this too. &lt;br /&gt;&lt;br /&gt;3 Now for the mask. Hit&lt;b&gt;Ctrl+F8&lt;/b&gt; again give the name as mask and draw a 100x100 circle of any color,it doesn't matter anyway. &lt;br /&gt;&lt;br /&gt;4. In the main stage create 4 additional layers and rename them , from top to bottom, Actions, Magnifier, Mask, Magnified, Original respectively. &lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_s6gSPX95als/SqXIXXVnIpI/AAAAAAAAAUw/_8xveTM4hKw/s1600-h/b4.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378925633691132562" src="http://4.bp.blogspot.com/_s6gSPX95als/SqXIXXVnIpI/AAAAAAAAAUw/_8xveTM4hKw/s400/b4.bmp" style="cursor: pointer; display: block; height: 97px; margin: 0px auto 10px; text-align: center; width: 189px;" /&gt;&lt;/a&gt; &lt;br /&gt;Except the Actions Layer you have to select the first frame and drag the respective object from the library and give the instance name as:- &lt;br /&gt;&lt;br /&gt;&lt;span style="color: #990000; font-weight: bold;"&gt; &lt;span style="color: #006600;"&gt;     Layer___&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_____&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__Object&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_____&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;___&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;                                 Instance Name&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;=====&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;___&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_____&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;======&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_____&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;                        =============&lt;/span&gt; &lt;span style="color: #990000; font-weight: bold;"&gt; &lt;br /&gt;Magnnifier&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;                                magnifier                                   &lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;m_mc&lt;/span&gt; &lt;span style="color: #990000; font-weight: bold;"&gt; &lt;br /&gt;Mask&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;                                                            mask&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;                                         mask_mc&lt;/span&gt; &lt;span style="color: #990000; font-weight: bold;"&gt; &lt;br /&gt;Magnified &lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;                               magnified &lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;                           mag_mc&lt;/span&gt; &lt;br /&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;Original&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;                                         original&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;__&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;&lt;span style="color: #006600;"&gt;_&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000; font-weight: bold;"&gt;                                      ori_mc&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;Hit Ctrl+A to select all the symbols and go to the Align Panel and centre them. Now Right-Click on the mask layer and select "Mask" from the menu. &lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_s6gSPX95als/SqXIX-qztjI/AAAAAAAAAU4/xRYecr1Czk0/s1600-h/b4_1.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378925644249019954" src="http://2.bp.blogspot.com/_s6gSPX95als/SqXIX-qztjI/AAAAAAAAAU4/xRYecr1Czk0/s400/b4_1.bmp" style="cursor: pointer; display: block; height: 95px; margin: 0px auto 10px; text-align: center; width: 192px;" /&gt;&lt;/a&gt; &lt;br /&gt;Your Stage should now look like this &lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_s6gSPX95als/SqXJTN9W80I/AAAAAAAAAVA/9-5pc1IT1T8/s1600-h/b4_2.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378926661965640514" src="http://2.bp.blogspot.com/_s6gSPX95als/SqXJTN9W80I/AAAAAAAAAVA/9-5pc1IT1T8/s400/b4_2.bmp" style="cursor: pointer; display: block; height: 212px; margin: 0px auto 10px; text-align: center; width: 211px;" /&gt;&lt;/a&gt; &lt;br /&gt;5.Now select the first frame of the Actions Layer and Hit F9 to bring up the actions Layer. Copy and paste the following code &lt;br /&gt;&lt;br /&gt;&lt;span style="color: grey;"&gt;/*add a listener*/&lt;/span&gt; &lt;br /&gt;&lt;span style="color: #3333ff;"&gt;addEventListener(Event.ENTER_FRAME&lt;/span&gt;,glassMove); &lt;br /&gt;&lt;br /&gt;&lt;span style="color: grey;"&gt;/*For a proper effect the magnified image must move &lt;br /&gt;so as to give a believable illusion. These variables &lt;br /&gt;will hold the amount to be moved along each axis*/&lt;/span&gt; &lt;br /&gt;&lt;span style="color: #3333ff;"&gt;var&lt;/span&gt;  moveX,moveY; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: grey;"&gt;/*hide the mouse*/&lt;/span&gt; &lt;br /&gt;&lt;span style="color: #3333ff;"&gt;Mouse.hide&lt;/span&gt;(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #3333ff;"&gt;function&lt;/span&gt;  glassMove(e:&lt;span style="color: #3333ff;"&gt;Event&lt;/span&gt;) { &lt;br /&gt;&lt;br /&gt;&lt;span style="color: grey;"&gt;/*make the magnifying glass and the mask move along &lt;br /&gt;with the mouse*/&lt;/span&gt; &lt;br /&gt;glass_mc.&lt;span style="color: #3333ff;"&gt;x&lt;/span&gt;=m_mc.&lt;span style="color: #3333ff;"&gt;x&lt;/span&gt;=&lt;span style="color: #3333ff;"&gt;mouseX&lt;/span&gt;; &lt;br /&gt;glass_mc.&lt;span style="color: #3333ff;"&gt;y&lt;/span&gt;=m_mc.&lt;span style="color: #3333ff;"&gt;y&lt;/span&gt;=&lt;span style="color: #3333ff;"&gt;mouseY&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: grey;"&gt;/*calculate the amount by which the magnified image has to move*/&lt;/span&gt; &lt;br /&gt;moveX = ( ((mag_mc.&lt;span style="color: #3333ff;"&gt;width&lt;/span&gt;-ori_mc.&lt;span style="color: #3333ff;"&gt;width&lt;/span&gt;)/2) * (glass_mc.&lt;span style="color: #3333ff;"&gt;x&lt;/span&gt;-ori_mc.&lt;span style="color: #3333ff;"&gt;x&lt;/span&gt;) )/(ori_mc.&lt;span style="color: #3333ff;"&gt;width&lt;/span&gt;/2); &lt;br /&gt;moveY = ( ((mag_mc.&lt;span style="color: #3333ff;"&gt;height&lt;/span&gt;-ori_mc.&lt;span style="color: #3333ff;"&gt;height&lt;/span&gt;)/2) * (glass_mc.&lt;span style="color: #3333ff;"&gt;y&lt;/span&gt;-ori_mc.&lt;span style="color: #3333ff;"&gt;x&lt;/span&gt;) )/(ori_mc.&lt;span style="color: #3333ff;"&gt;height&lt;/span&gt;/2); &lt;br /&gt;&lt;br /&gt;&lt;span style="color: grey;"&gt;/*move the magnified image by the calculated amount &lt;br /&gt;(200,200) is the centre of the stage hence the centre of mag_mc and ori_mc*/&lt;/span&gt; &lt;br /&gt;mag_mc.&lt;span style="color: #3333ff;"&gt;x&lt;/span&gt;=200-moveX; &lt;br /&gt;mag_mc.&lt;span style="color: #3333ff;"&gt;y&lt;/span&gt;=200-moveY; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: grey;"&gt;/*restrict the movement so that both the magnified image &lt;br /&gt;and the diminished image appear at the same time when &lt;br /&gt;magnifying along the edges.If the top left corner of the &lt;br /&gt;two images coincide then the centre of mag_mc will be(375,375). &lt;br /&gt;If the top left corner of the two images coincide then &lt;br /&gt;the centre of mag_mc will be(75,75)*/&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(mag_mc.&lt;span style="color: blue;"&gt;x&lt;/span&gt;&amp;lt;75)&lt;br /&gt;mag_mc.&lt;span style="color: blue;"&gt;x&lt;/span&gt;=75;&lt;br /&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(mag_mc.&lt;span style="color: blue;"&gt;x&lt;/span&gt;&amp;gt;325)&lt;br /&gt;mag_mc.&lt;span style="color: blue;"&gt;x&lt;/span&gt;=325;&lt;br /&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(mag_mc.&lt;span style="color: blue;"&gt;y&lt;/span&gt;&amp;lt;75)&lt;br /&gt;mag_mc.&lt;span style="color: blue;"&gt;y&lt;/span&gt;=75;&lt;br /&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(mag_mc.&lt;span style="color: blue;"&gt;y&lt;/span&gt;&amp;gt;325)&lt;br /&gt;mag_mc.&lt;span style="color: blue;"&gt;y&lt;/span&gt;=325;} &lt;br /&gt;&lt;br /&gt;Hit Ctrl+Enter to test your movie!! &lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_s6gSPX95als/SqXJTXZI3qI/AAAAAAAAAVI/of1-5_mVAZo/s1600-h/b5.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378926664498077346" src="http://1.bp.blogspot.com/_s6gSPX95als/SqXJTXZI3qI/AAAAAAAAAVI/of1-5_mVAZo/s400/b5.bmp" style="cursor: pointer; display: block; height: 172px; margin: 0px auto 10px; text-align: center; width: 173px;" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-1287457934201906152?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/1287457934201906152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-magnifying-glass-effect-in.html#comment-form' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/1287457934201906152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/1287457934201906152'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-magnifying-glass-effect-in.html' title='Create a Magnifying Glass Effect in Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_s6gSPX95als/SqXIWTWcTgI/AAAAAAAAAUY/2C4JviYScNc/s72-c/b1_1.bmp' height='72' width='72'/><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-7756353632059936409</id><published>2009-09-04T11:08:00.000+05:30</published><updated>2009-09-04T11:16:25.905+05:30</updated><title type='text'>Pasre through the ID3 tags of an MP3 file with Actionscript 3</title><content type='html'>ID3 tags are the metadata attached to the mp3 files by the encoder. This contains information like the&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;#Song Name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;#Artist&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;#Album&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;#Year&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;#Genre&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;#Comment&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;#Track Number.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is how you access these data in flash:-&lt;br /&gt;Hit &lt;span style="font-weight: bold;"&gt;Ctrl+j&lt;/span&gt; and bring up the Document Properties window and set both the width and height to 300 pixels. Select the first frame of the layer and hit F9 to bring up the Actions window. Copy and Paste the following code&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-style: italic;color:gray;" &gt;/*Load the sound and play it though playing is not necessary for&lt;br /&gt;         viewing the ID3 tags*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mySound:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Sound&lt;/span&gt;&lt;span style="font-style: italic;"&gt; =&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; new Sound&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new URLRequest&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"myMusic.mp3"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        mySound.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;play&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;      &lt;span style="font-style: italic;color:gray;" &gt;/*Define a text field to view the tags*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        var id3Text:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;TextField&lt;/span&gt;&lt;span style="font-style: italic;"&gt; =&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; new TextField&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=50;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=50;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;autoSize&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;TextFieldAutoSize.LEFT&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*Resize keeping the upper left corner fixed*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(id3Text);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-style: italic;color:gray;" &gt;/*Display tags on completion of loading*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        mySound.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event.COMPLETE&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,onId3);&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;      &lt;span style="font-style: italic;color:gray;" &gt;/*display the id3 tags*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  onId3(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;appendText&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"Song : "&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+ mySound.&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;id3&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;songName&lt;/span&gt;&lt;span style="font-style: italic;"&gt; +&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt; "\n"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;appendText&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"Artist : "&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+ mySound.&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;id3&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;artist&lt;/span&gt;&lt;span style="font-style: italic;"&gt; + &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt; "\n"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;appendText&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"Album : "&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+ mySound.&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;id3&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;album &lt;/span&gt;&lt;span style="font-style: italic;"&gt;+ &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt; "\n"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;appendText&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"Track No. : "&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+ mySound.&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;id3&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;track&lt;/span&gt;&lt;span style="font-style: italic;"&gt; + &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt; "\n"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;appendText&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"Year : "&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+ mySound.&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;id3&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;year&lt;/span&gt;&lt;span style="font-style: italic;"&gt; + &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt; "\n"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            id3Text.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;appendText&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"Comment : "&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+ mySound.&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;id3&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;comment&lt;/span&gt;&lt;span style="font-style: italic;"&gt; + &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt; "\n"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hit &lt;span style="font-weight: bold;"&gt;Ctrl+Enter&lt;/span&gt; to test your movie. Your tags should appear like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SqCoHNefUqI/AAAAAAAAAUQ/Ao8AkZURjag/s1600-h/1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 213px; height: 258px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SqCoHNefUqI/AAAAAAAAAUQ/Ao8AkZURjag/s400/1.bmp" alt="" id="BLOGGER_PHOTO_ID_5377482796910465698" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-7756353632059936409?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/7756353632059936409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/id3-tags-are-metadata-attached-to-mp3.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/7756353632059936409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/7756353632059936409'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/id3-tags-are-metadata-attached-to-mp3.html' title='Pasre through the ID3 tags of an MP3 file with Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_s6gSPX95als/SqCoHNefUqI/AAAAAAAAAUQ/Ao8AkZURjag/s72-c/1.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-812585094013243208</id><published>2009-09-04T10:53:00.000+05:30</published><updated>2009-09-04T21:00:05.001+05:30</updated><title type='text'>Create a Dynamic Music Visualisation for your MP3 player with Actionscript 3</title><content type='html'>We will create a dynamic visualisation which responds to the beats of the music being played with the SoundMixer.computeSpectrum() method;&lt;br /&gt;&lt;br /&gt;First hit &lt;b&gt;Ctrl+J&lt;/b&gt; and bring up the Document Properties window and set the width and height to 400 and 200 pixels respectively.&lt;br /&gt;Now hit &lt;b&gt;Ctrl+F8&lt;/b&gt; to bring up the &lt;b&gt;New Symbol&lt;/b&gt; window and type in the name as play_mc and click OK. Draw a small rectangle and centre it using the &lt;b&gt;Align Window&lt;/b&gt;. Now Select the &lt;b&gt;Text Tool&lt;/b&gt; , and go to the &lt;b&gt;Properties Panel&lt;/b&gt; and select the text type to Static Text. Now create a label fo your button. Mine looks like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SqClAySvucI/AAAAAAAAAUA/ByakLOh0_kY/s1600-h/1_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 97px; height: 53px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SqClAySvucI/AAAAAAAAAUA/ByakLOh0_kY/s400/1_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5377479387999353282" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now go to the Main Stage ang Drag the play_mc button on Stage from the library. Go to the &lt;b&gt;Properties Panel&lt;/b&gt; and type in the instance name as play_mc.&lt;br /&gt;Create a new Layer, name it actions, select the first frame and hit &lt;b&gt;F9&lt;/b&gt; to bring up the &lt;b&gt;Actions Window&lt;/b&gt;. Copy and Paste the foll0wing code&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; bytes:&lt;span style="color: rgb(51, 51, 255);"&gt;ByteArray = new ByteArray&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*this varible defines the size of the visualisation*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt; amplify=40;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*load the mp3 file*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mySound:&lt;span style="color: rgb(51, 51, 255);"&gt;Sound&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new Sound(new URLRequest&lt;/span&gt;(&lt;span style="color: rgb(0, 153, 0);"&gt;"myMusic.mp3"&lt;/span&gt;));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*listen for the click on the play button,then play*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;play_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(MouseEvent.CLICK&lt;/span&gt;,playMusic);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*play the music*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  playMusic(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; mySound.&lt;span style="color: rgb(51, 51, 255);"&gt;play&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener(Event.ENTER_FRAME&lt;/span&gt;,displaySpectrum);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color:gray;"&gt;/*display the visualisation*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; displaySpectrum(evt:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;void&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;SoundMixer.computeSpectrum&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(bytes, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;, 0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; graphics.clear&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 0; i &lt;&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineStyle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(.5,0x00FF66, 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; val:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = bytes.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;readFloat&lt;/span&gt;&lt;span style="font-style: italic;"&gt;() * amplify;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (i = 0; i &lt;&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            val = bytes.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;readFloat&lt;/span&gt;&lt;span style="font-style: italic;"&gt;() * amplify;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;            /*first spectrum. Unequal Values of the X coordinate&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                in moveTo and lineTo give the spectrum a jagged &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                look. Equal values result in a symmetrical spectrum */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.moveTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i+50, -val+40 );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i+90, val+40);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;span style="color:gray;"&gt;/*second spectrum*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; graphics.moveTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i+50, -val+100 );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i+90, val+100);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;Remember the myMusic.mp3 should be in the same directory as the .swf file. Hit Ctrl+Enter to test the movie!!&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SqClBIvbxKI/AAAAAAAAAUI/XBH2pLZvs9I/s1600-h/1_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 200px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SqClBIvbxKI/AAAAAAAAAUI/XBH2pLZvs9I/s400/1_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5377479394025260194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-812585094013243208?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/812585094013243208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-dynamic-music-visualisation-for.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/812585094013243208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/812585094013243208'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/create-dynamic-music-visualisation-for.html' title='Create a Dynamic Music Visualisation for your MP3 player with Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_s6gSPX95als/SqClAySvucI/AAAAAAAAAUA/ByakLOh0_kY/s72-c/1_1.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-7668064580553038156</id><published>2009-09-01T19:41:00.000+05:30</published><updated>2009-09-08T08:40:48.357+05:30</updated><title type='text'>Make Your Own Custom Minesweeper Game with Actionscript 3</title><content type='html'>We'll make a variant of the very popular Minesweeper. This will also give you a very clear idea on how to go about creating games in Flash.&lt;br /&gt;&lt;br /&gt;&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="minesweeper" align="" height="300" width="300"&gt;&lt;br /&gt;&lt;param name="movie" value="http://www.fileden.com/files/2009/9/5/2565234/minesweeper.swf"&gt; &lt;param name="quality" value="high"&gt; &lt;param name="bgcolor" value="#339966"&gt; &lt;embed src="http://www.fileden.com/files/2009/9/5/2565234/minesweeper.swf" quality="high" bgcolor="#339966" name="minesweeper" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="" height="300" width="300"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;br /&gt;&lt;br /&gt;1. First hit &lt;b&gt;Ctrl+J&lt;/b&gt; to bring up the properties window and set BOTH the width and height of the stage to 300 and the Background to the color #339966;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Now we'll draw the required components. For each, hit &lt;b&gt;Ctrl+F8&lt;/b&gt; to bring up the &lt;b&gt;New Symbol Window&lt;/b&gt; and select the &lt;b&gt;Export For Actionscript&lt;/b&gt; in the &lt;b&gt;Advanced&lt;/b&gt; section. Maintain the dimensions i mention if you do not want to tweek the script.&lt;br /&gt;First the boxes. This will create a mesh background to the minefield. Give the name in the &lt;b&gt;New Symbol Window&lt;/b&gt; as box_mc.Click Ok and select the &lt;b&gt;Rectangle Tool&lt;/b&gt; and Change the Stroke Color to #A6A6A6 and &lt;b&gt;No&lt;/b&gt; Fill Color. Draw a 24x24 sized square and select the Top and Left edges and change their color to Black. Now go to the Align Panel and Click on Align Left anf Align Top so that the top left corner coincides with the small cross on the stage. If you do this correctly it sould look like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sFyIEo5I/AAAAAAAAASg/d5oUEUEX-OM/s1600-h/b2_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 129px; height: 122px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sFyIEo5I/AAAAAAAAASg/d5oUEUEX-OM/s400/b2_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502008016839570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now the Mines.     Again in the &lt;b&gt;New Symbol Window&lt;/b&gt; give the name as mine_mc and make sure Export For Actionscript is selected. Draw it anyway you want just make sure they are smaller than your boxes. My mines are of the size 20x20 and look like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Sp0sGMAsJGI/AAAAAAAAASo/BeZDxy1aQso/s1600-h/b2_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 111px; height: 120px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Sp0sGMAsJGI/AAAAAAAAASo/BeZDxy1aQso/s400/b2_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502014965195874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;For the box covers give the name as cover_mc draw a 23x23 rectangle with Stroke Thickness 2 and fill color #0066CC and Stroke Colors #012B54 and #81C0FE Align the Top-Left corner,similar to the box_mc, to make it look like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sGq1lz5I/AAAAAAAAASw/FUfccSrJk3g/s1600-h/b2_3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 110px; height: 111px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sGq1lz5I/AAAAAAAAASw/FUfccSrJk3g/s400/b2_3.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502023240142738" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Name the flags flag_mc and they should, again, be smaller than the boxes.This one measures 15x18.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sHAtXLKI/AAAAAAAAAS4/T6gdKleelY0/s1600-h/b2_4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 98px; height: 112px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sHAtXLKI/AAAAAAAAAS4/T6gdKleelY0/s400/b2_4.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502029111209122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;For the following three objects you need not check the &lt;b&gt;Export for Actionscript&lt;/b&gt; Box.&lt;br /&gt;The timer sould be named timer_mc. First Draw a 60x30 Rectangle with the  color #540101 with an alpha of 75. That done select the &lt;b&gt;Text Tool&lt;/b&gt; and draw Dynamic Text Field like so&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sHUHOeiI/AAAAAAAAATA/X4ESIJAV-KE/s1600-h/b2_5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 138px; height: 82px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sp0sHUHOeiI/AAAAAAAAATA/X4ESIJAV-KE/s400/b2_5.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502034319964706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Select the text field and go to the Properties Panel and give it the instance name of time_txt.&lt;br /&gt;&lt;br /&gt;Now for the final two components, the game lose and win splash screens. Hit &lt;b&gt;Ctrl+F8&lt;/b&gt; again and name it lose_mc. Draw a 225x225 square of the color #91000 and alpha 25. Centre it and create &lt;b&gt;Static Text&lt;/b&gt; fields to write "You Lose" or whatever you want to indicate that the player has lost.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Sp0s5_v1ASI/AAAAAAAAATI/jQfo9INkJl4/s1600-h/b2_6.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 228px; height: 227px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Sp0s5_v1ASI/AAAAAAAAATI/jQfo9INkJl4/s400/b2_6.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502905026445602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Follow the Exact same procedure and create a game win splash screen and name it win_mc, set the color to #00CC33 and change the text to "You Win" or something similar.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Sp0s6bHdjXI/AAAAAAAAATQ/qvNZb_9sc6M/s1600-h/b2_7.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 233px; height: 233px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Sp0s6bHdjXI/AAAAAAAAATQ/qvNZb_9sc6M/s400/b2_7.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502912373329266" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3. Till Now your Main Stage should be empty. Add a total of 3 new layer. Rename the top layer Actions, the next one Win, the next one Lose and the last one Timer. Select the Timer Layer and select the first frame. Now open your Library Window and drag an instance of timer_mc on to the stage. Go to the properties panel. Enter its instance name of timer_mc and set its X and Y coordinates to 150 and 2 respectively. Similarly drag the lose_mc on to the first frame of the Lose Layer and set the instance name as "lose_mc" and both the coordinates as 150. win_mc should be dragged on to the Win layer. The instance should be named as win_mc. Your stage should look like this.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Sp0s6jbGMjI/AAAAAAAAATY/CkKv-ZECvT0/s1600-h/b3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 302px; height: 302px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Sp0s6jbGMjI/AAAAAAAAATY/CkKv-ZECvT0/s400/b3.bmp" alt="" id="BLOGGER_PHOTO_ID_5376502914603168306" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;4. Now time for some major scripting! Remember we are creating a 9x9 game with 10 mines. So there will be 81 boxes and box covers and 10 flags.&lt;br /&gt;The boxes are logically defined as an Array of length 81. The value gives the number of mines in the adjacent boxes&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-------------------INITIATE GAME-----------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*define the top left corner the mineField*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; X=37.5    ,Y=37.5;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*hide the two game end splash screens*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           lose_mc.visible = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           win_mc.visible = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*global variables*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; isLost=0;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*flags game lose scenario*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; isPlaying=0;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*shows if the game is in progress*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; timeCount=0;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*counts the number of seconds*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; removedCount=0;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*counts the number of boxws uncovered*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*holds the positions of the 10 mines*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; minePos:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Array = new Array&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*for every box counts the number of adjacent mines*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mineCount:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Array = new Array&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*this will time the game*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; timer:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Timer = new Timer&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(1000);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           timer.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(TimerEvent.TIMER&lt;/span&gt;&lt;span style="font-style: italic;"&gt;, onTimer);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           function  onTimer(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;TimerEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                 &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(isPlaying==1)&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*start timing only if the game is in progress*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                        timeCount++;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                 timer_mc.time_txt&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;.text&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = timeCount;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                 timer_mc.time_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;selectable&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*This is the format for the text in each box&lt;br /&gt;          indicating the number of adjacent mines*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           var format:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;TextFormat = new TextFormat&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           format.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;bold&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = true;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           format.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;color&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 0x0000FF;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           format.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;blockIndent&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 5;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           format.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;size&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 22;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*Now we define the starting function which in turn calls all other necessary functions*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  createNewGame() {&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*set the initial mine counters*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i=0;i&lt;81;i++)&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*attach the 10 mines*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           attachMines();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*create the rest of the minefield*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           createMineField();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*attach the 10 marker flags*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           attachFlags();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*start the timer*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           timer.start();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*Call the function so that all required components are attached to the stage.*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*/&lt;/span&gt;&lt;span style="font-style: italic;"&gt;////////////&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       createNewGame();&lt;/span&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*/&lt;/span&gt;&lt;span style="font-style: italic;"&gt;////////////&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*--------------ATTACH MINES---------------------    */&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*Randomly decides upon 10 places to put the mines.&lt;br /&gt;Since the same number may be returned  by the Math.random()&lt;br /&gt;function we have the 2nd loop. What it does is calls itself&lt;br /&gt;if it finds two same number in the array. Since this may happen&lt;br /&gt;sparsely the recursive call does not incur a great cost.*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  findMinePos() {&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*randomly find 10 mine positions*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(var i=0;i&lt;10;i++)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Math.random()*80);&lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*to prevent the same number being chosen twice*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i=0;i&lt;10;i++)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(var j=i+1;j&lt;10;j++)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(minePos[i]==minePos[j])&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                       findMinePos();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*Now that 10 distinct locations has been chosen,&lt;br /&gt;      this function actually attaches the mines to these.&lt;br /&gt;      If you have used a different dimension for the mines&lt;br /&gt;      and/or boxes than i have you may have to tweek the&lt;br /&gt;      values in the script for proper alignment. */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function &lt;/span&gt;&lt;span style="font-style: italic;"&gt; attachMines() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           findMinePos();&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i=0;i&lt;10;i++)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mine = new mine_mc();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               mine.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=X+(minePos[i]%9)*25+12.5;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               mine.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=Y+int (minePos[i]/9)*25+12.5;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               updateMineCount(minePos[i]);&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(mine);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Now we have to understand since the boxes are defined as a 81 lentgh array, for any box X what the indeces for the adjacent boxes are--&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Sp0s7CiMroI/AAAAAAAAATg/sQhi5uIifmo/s1600-h/b4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 359px; height: 270px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Sp0s7CiMroI/AAAAAAAAATg/sQhi5uIifmo/s400/b4.jpg" alt="" id="BLOGGER_PHOTO_ID_5376502922954452610" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;for a box on the Left edge the indeces would be like 0,9,18,27...X.. i.e. X%9 = 0 and their adjacent boxes are&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Sp0s7SzFg0I/AAAAAAAAATo/uWjfKEkZqW4/s1600-h/b4_1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 257px; height: 275px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Sp0s7SzFg0I/AAAAAAAAATo/uWjfKEkZqW4/s400/b4_1.jpg" alt="" id="BLOGGER_PHOTO_ID_5376502927320253250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;and for one on the Right edge the indeces are 8,17,26,...X,... i.e X%9 = 8 and their adjacent boxes are&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Sp0xbLydVFI/AAAAAAAAATw/ilLQL2s728Q/s1600-h/b4_2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 239px; height: 270px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Sp0xbLydVFI/AAAAAAAAATw/ilLQL2s728Q/s400/b4_2.jpg" alt="" id="BLOGGER_PHOTO_ID_5376507873240896594" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*this funcion takes the position of a mine&lt;br /&gt;      and updates all its adjacent boxes */&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       function  updateMineCount(pos:Number) {&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*set the value of the position with the mine*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           mineCount[pos]=9;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos+9&gt;0&amp;amp;&amp;amp;pos+9&lt;81)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos-9&gt;=0&amp;amp;&amp;amp;pos-9&lt;81)&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*for all boxes NOT on the right edge*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos%9!=8)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           {&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos+9+1&gt;0&amp;amp;&amp;amp;pos+9+1&lt;81)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos+1&gt;0&amp;amp;&amp;amp;pos+1&lt;81)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos-9+1&gt;=0&amp;amp;&amp;amp;pos-9+1&lt;81)&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*for all boxes NOT on the left edge*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos%9!=0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           {&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos-9-1&gt;=0&amp;amp;&amp;amp;pos-9-1&lt;81)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos-1&gt;=0&amp;amp;&amp;amp;pos-1&lt;81)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos+9-1&gt;0&amp;amp;&amp;amp;pos+9-1&lt;81)&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-----------------CREATE REST OF THE MINEFIELD-------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  createMineField() {&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(var i=0;i&lt;81;i++)&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*....Attach Boxes..........*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               var b_mc=new box_mc();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               b_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=X+(i%9)*25;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               b_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=Y+int(i/9)*25;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               b_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;name&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"b"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;+i+&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"_mc"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(b_mc);&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*.........................*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*.......Attach Text Fields.............*/&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(mineCount[i]!=0&amp;amp;&amp;amp;mineCount[i]&lt;9)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; t_txt:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;TextField=new TextField&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   t_txt.selectable = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   t_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=X+(i%9)*25;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   t_txt&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;.y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=Y+int(i/9)*25;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   t_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = mineCount[i];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   t_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;setTextFormat&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(format);&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(t_txt);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               }&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*.........................................*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*.............Attach Box Covers............*/&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; cover=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new&lt;/span&gt;&lt;span style="font-style: italic;"&gt; cover_mc();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               cover.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=X+.5+(i%9)*25;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               cover.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=Y+.5+int(i/9)*25;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               cover.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;name&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = "c"+i;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               cover.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.CLICK&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,clickHandler);&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(cover);&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*............................................*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*------------MineCover Click Handler-------------------*/&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  clickHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           isPlaying=1;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Name = e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.name.toString&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; clickedBut=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Name.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;substr&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(1,2));&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*if clicked on a mine invoke procedure lose*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i=0;i&lt;10;i++)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(minePos[i]==clickedBut)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   lost();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*if clicked on a box with no adjacent mines remove&lt;br /&gt;          all adjcent empty boxes*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(mineCount[clickedBut]==0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               getAdjacentEmptyFields(clickedBut);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               begin=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               end=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*for all other boxes remove the cover and reveal&lt;br /&gt;          the number of adjacent mines*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;else if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(mineCount[clickedBut]&lt;9)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;removeChild(getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.c&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;urrentTarget.name&lt;/span&gt;&lt;span style="font-style: italic;"&gt;));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               updateRemovedCount();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*------Remove all adjacent empty boxes-------------------*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*this function uses a queue and two functions enqueue and dequeue&lt;br /&gt;  to work on the queue.When a box with no adjacent mines is clicked&lt;br /&gt;  this function searches through all its adjacent boxes and removes the&lt;br /&gt;  covers if it does not hide a mine and if an empty box is encountered&lt;br /&gt;  it is put in the queue and later taken up for processing. In this way&lt;br /&gt;  if you click on an empty box an area is cleared up;     &lt;br /&gt;      */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; queue:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Array=new Array&lt;/span&gt;&lt;span style="font-style: italic;"&gt; ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*beginning of the array*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; begin=0;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*end of the array*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; end=0;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*takes a number and inserts into the end of the queue*/&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  enqueue(num:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           queue[end]=num;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           end++;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*retrieves the number in front of the queue*/&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  dequeue():&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;return&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(queue[begin++]);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  getAdjacentEmptyFields(pos:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Name:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String = new String&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           Name = "c"+pos;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*remove cover*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Name))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           {&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;removeChild(getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Name));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               updateRemovedCount();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*flag cover removal of an empty box&lt;br /&gt;          in the array*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           mineCount[pos]=99;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*..................Process Adjacent Boxes....................*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           processAdjacentBoxes(pos+9);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           processAdjacentBoxes(pos-9);&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos%9!=8)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               processAdjacentBoxes(pos+9+1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               processAdjacentBoxes(pos+1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               processAdjacentBoxes(pos-9+1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos%9!=0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               processAdjacentBoxes(pos-9-1);      &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               processAdjacentBoxes(pos-1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               processAdjacentBoxes(pos+9-1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*......................................................*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*return if queue is empty*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(begin&gt;=end&amp;amp;&amp;amp;begin!=0)&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;return&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*process the position at the start of the queue*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           getAdjacentEmptyFields(dequeue());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*process the position passed as argument*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  processAdjacentBoxes(pos:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Number&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Name:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String = new String&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(pos&gt;0&amp;amp;&amp;amp;pos&lt;81)&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if empty box put it in the queue and&lt;br /&gt;          flag removal of cover of the empty box*/&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(mineCount[pos]==0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   mineCount[pos]=99;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   enqueue(pos);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               }&lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;           &lt;span style="font-style: italic;color:gray;" &gt;/*else if a box with text remove the cover only*/&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;else if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(mineCount[pos]&lt;9) name="c"&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if(getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Name))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   {&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; removeChild(getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Name));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                       updateRemovedCount();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               }          &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-----------------------FLAGS----------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*The flags will be for marking purpose only and their position have&lt;br /&gt;  no bearing on the result whatsoever you have to remove all unmined&lt;br /&gt;  box covers to win*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  attachFlags() {&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i=0;i&lt;10;i++)&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; flag=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new&lt;/span&gt;&lt;span style="font-style: italic;"&gt; flag_mc();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               flag.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=X+i*24;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               flag.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=Y+227;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               flag.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.MOUSE_DOWN&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,dragFlag);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               flag.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.MOUSE_UP&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,stopDragFlag);&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(flag);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function &lt;/span&gt;&lt;span style="font-style: italic;"&gt; dragFlag(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.startDrag&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  stopDragFlag(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.stopDrag(&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-----------------------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/**********************Results**************************************/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*This function is called every time a box cover is removed&lt;br /&gt;      if all 71 (81-10) unmined boxes are uncovered the game is won&lt;br /&gt;  */&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  updateRemovedCount() {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           removedCount++;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(removedCount==71&amp;amp;&amp;amp;isLost==0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           {&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*game has been won*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               win_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;visible&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=true;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               isPlaying=0;&lt;/span&gt;&lt;br /&gt;           &lt;span style="font-style: italic;color:gray;" &gt;/*bring the splash screen to the top*/&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;setChildIndex&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(win_mc,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;numChildren&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  lost() {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; Name:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String = new String&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*remove all the covers of mined boxes to reveal their positions*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i=0;i&lt;10;i++) name = "c"&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; if(getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Name))&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;removeChild(getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Name));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               isLost=1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               isPlaying=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               lose_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;visible&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;           &lt;span style="font-style: italic;color:gray;" &gt;/*bring the splash screen to the top*/&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;setChildIndex&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(lose_mc,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;numChildren&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*---------------------------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Thats it!!&lt;br /&gt;Hit &lt;b&gt;Ctrl+Enter&lt;/b&gt; to test your movie. Happy gaming.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Sp0xbr-X1rI/AAAAAAAAAT4/R9GjNC1VSno/s1600-h/b5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 304px; height: 304px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Sp0xbr-X1rI/AAAAAAAAAT4/R9GjNC1VSno/s400/b5.bmp" alt="" id="BLOGGER_PHOTO_ID_5376507881880802994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-7668064580553038156?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/7668064580553038156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/make-your-own-custom-minesweeper-game.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/7668064580553038156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/7668064580553038156'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/09/make-your-own-custom-minesweeper-game.html' title='Make Your Own Custom Minesweeper Game with Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_s6gSPX95als/Sp0sFyIEo5I/AAAAAAAAASg/d5oUEUEX-OM/s72-c/b2_1.bmp' height='72' width='72'/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-6094377973649907168</id><published>2009-08-29T18:15:00.000+05:30</published><updated>2009-08-29T18:23:59.254+05:30</updated><title type='text'>Interface Flash with PHP in ActionScript 3</title><content type='html'>Interface Flash with PHP in ActionScript 3&lt;br /&gt;We will interface Flash and PHP pass variables from Flash to PHP with the POST method&lt;br /&gt;&lt;br /&gt;1. First we do not need a big Stage so create a new flash file, name it "phpFlash.fla" and hit &lt;b&gt;Ctrl+J&lt;/b&gt; to bring up the document properties window and change the stage width and height to 250 and 200 resp.&lt;br /&gt;2. Select the Text Tool and go to the properties panel and select &lt;b&gt;Input Text&lt;/b&gt; and click on &lt;b&gt;Show border around text&lt;/b&gt;. Now create three text fields like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SpkkHROglEI/AAAAAAAAARs/ii1JimkIlBY/s1600-h/b2_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 165px; height: 110px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SpkkHROglEI/AAAAAAAAARs/ii1JimkIlBY/s400/b2_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5375367337545339970" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;go to the properties panel and give them instance names of "fName_txt", "lName_txt", "email_txt" resp.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Now Change the text type to &lt;b&gt;Static&lt;/b&gt; and create labels for the input text boxes like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SpkkG8BDn2I/AAAAAAAAARk/H8kBg0iuqh0/s1600-h/b3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 220px; height: 116px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SpkkG8BDn2I/AAAAAAAAARk/H8kBg0iuqh0/s400/b3.bmp" alt="" id="BLOGGER_PHOTO_ID_5375367331851771746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;4. Now Hit &lt;b&gt;Ctrl+F8&lt;/b&gt; to bring up the &lt;b&gt;New Symbol&lt;/b&gt; window. Name it submit_mc. draw your own button and Label it "Submit". Now return to the main Stage and drag the instance of the button on the Stage from the Library window.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SpkkGUeFhtI/AAAAAAAAARc/buJeuik2rko/s1600-h/b4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 194px; height: 144px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SpkkGUeFhtI/AAAAAAAAARc/buJeuik2rko/s400/b4.bmp" alt="" id="BLOGGER_PHOTO_ID_5375367321236113106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Go to the Properties Panel and give it the instance name of submit_mc.&lt;br /&gt;&lt;br /&gt;5. Next create a new Layer, rename it "Actions" and select the first frame. Hit F9 to bring up the Actions Window nad copy and paste the following piece of code&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="color:gray;"&gt;/*Wait for the button to be clicked*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    submit_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.CLICK,postData);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    function  postData(e:MouseEvent) {        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; myRequest:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;URLRequest&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new URLRequest&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"phpFlash.php"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; variables:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;URLVariables&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new URLVariables&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*These will be the $_POST variables*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        variables.fname = fName_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        variables.lname = lName_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        variables.Email =  email_txt.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;text&lt;/span&gt;&lt;span style="font-style: italic;"&gt;; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*assign the URL variables to the request*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        myRequest.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;data&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = variables;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*Select the request method as POST*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        myRequest.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;method&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;URLRequestMethod.POST&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;span style="color:gray;"&gt;/*go to the given page*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;navigateToURL&lt;/span&gt;&lt;span style="font-style: italic;"&gt;( myRequest);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hit &lt;span style="font-weight: bold;"&gt;Ctrl+Enter&lt;/span&gt; to get your phpFlash.swf file.&lt;br /&gt;&lt;br /&gt;6. Now we create the .php file. Name it phpFlash.php and open in a text editor. The .swf file will be embedded in this file itself. Copy and paste the following Script&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;body bgcolor="#ffffff"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;div align=middle&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;object width="550" height="400" id="c1" align="middle"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;param name="movie" value="phpFlash.swf" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;param name="quality" value="high" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;param name="bgcolor" value="#ffffff" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;embed src="phpFlash.swf" quality="high" bgcolor="#ffffff" width="250" height="200" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;/object&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;$fname=$_POST[fname];&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;$lname=$_POST[lname];&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;$email=$_POST[Email];&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;echo "First Name - ";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;echo $fname;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;echo "&amp;lt;/br&amp;gt;LastName - ";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;echo $lname;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;echo "&amp;lt;/br&amp;gt; Email - ";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;echo $email;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;?&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7. Make Sure the .swf and the .php files are in the same folder and in the root diretory of the server. Run the php file from a browser. Type in the boxes and hit Submit and Voila what you have typed will appear on stage through the PHP script. Hope you can use this in a much more complicated application of yours&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-6094377973649907168?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/6094377973649907168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/interface-flash-with-php-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/6094377973649907168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/6094377973649907168'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/interface-flash-with-php-in.html' title='Interface Flash with PHP in ActionScript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_s6gSPX95als/SpkkHROglEI/AAAAAAAAARs/ii1JimkIlBY/s72-c/b2_1.bmp' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-3383285220491441763</id><published>2009-08-29T07:47:00.000+05:30</published><updated>2009-08-29T08:23:12.887+05:30</updated><title type='text'>Create your own .flv Video Player with Timeline Seek Playhead</title><content type='html'>This is a progressive download .flv video player with play, pause and stop buttons with sliding volume controller and timeline seek&lt;br /&gt;&lt;br /&gt;There are two ways you can play a video. firstly you can embed the .flv video in the .swf file which creates very large and unmanageable files or you can dynamically load the video file which can be done in two ways. First is a streaming video but you will need the Flash Media Server for it or you can have progressive downloaded video like this one which does not need any additional softwares. The actual coding to play a both types of videos is more or less the same&lt;br /&gt;&lt;br /&gt;1. First we design the stage. Hit &lt;b&gt;Ctrl+J&lt;/b&gt; to bring up the document properties window. Select #333333 as the background color. Now create 2 more layers and name the top most Actions.&lt;br /&gt;2. Hit &lt;b&gt;Ctrl+F8&lt;/b&gt; to bring up the New Symbol window and give the name play_mc. Click on ok and create your own button. Mine looks like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SpiVupHoFuI/AAAAAAAAAQM/uapF3_oEAm4/s1600-h/b2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 63px; height: 30px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SpiVupHoFuI/AAAAAAAAAQM/uapF3_oEAm4/s400/b2.bmp" alt="" id="BLOGGER_PHOTO_ID_5375210783811049186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now repeat the above process twice and give in the names stop_mc and pause_mc.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SpiVvaEAUAI/AAAAAAAAAQc/7b2bSeJ1UpE/s1600-h/b2_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 58px; height: 29px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SpiVvaEAUAI/AAAAAAAAAQc/7b2bSeJ1UpE/s400/b2_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5375210796949196802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SpiVu1FIq9I/AAAAAAAAAQU/UTAjnqcSjCg/s1600-h/b2_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 65px; height: 30px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SpiVu1FIq9I/AAAAAAAAAQU/UTAjnqcSjCg/s400/b2_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5375210787021827026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;make sure atleast the play and pause buttons have exactly the same shape and size. Now select the first frame of the middle layer and drag the play_mc and stop_mc buttons from the library onto the stage and place them near the bottom. Give them instance names of play_mc and stop_mc&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SpiVvzWJ8oI/AAAAAAAAAQk/hFem8I68QkA/s1600-h/b2_4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 134px; height: 31px;" src="http://3.bp.blogspot.com/_s6gSPX95als/SpiVvzWJ8oI/AAAAAAAAAQk/hFem8I68QkA/s400/b2_4.bmp" alt="" id="BLOGGER_PHOTO_ID_5375210803736212098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;now select the first frame of the bottom most layer and drag the pause button onto it from the library. Give the instance name pause_mc, now from the properties panel set the x and y coordinates of the pause button to be same as that of the play button.Since the pause button is exactly of the same shape and size and is on a lower layer it will be completely hidden.&lt;br /&gt;&lt;br /&gt;3.Now again select the first frame of the bottom most layer draw a small line on the side of the buttons with lentgh of 100. make a note of the x and y coordinates. Here its 240 and 385 resp.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SpiVwToGiaI/AAAAAAAAAQs/qT-65HTxoDQ/s1600-h/b3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 262px; height: 73px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SpiVwToGiaI/AAAAAAAAAQs/qT-65HTxoDQ/s400/b3.bmp" alt="" id="BLOGGER_PHOTO_ID_5375210812401420706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Hit &lt;b&gt;Ctrl+F8&lt;/b&gt; again and this time give the name slider_mc and draw a 16x16 black sqaure and centre it. Go back to the main stage and select the first frame of the middle layer and drag the slider_mc from the library onto the stage and set its coordinates as 340 (240+100) and 385. Give it the instance name of slider_mc in the properties panel&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SpiWfHvIlzI/AAAAAAAAARU/pGyUC225ydE/s1600-h/b3_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 128px; height: 31px;" src="http://3.bp.blogspot.com/_s6gSPX95als/SpiWfHvIlzI/AAAAAAAAARU/pGyUC225ydE/s400/b3_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5375211616663541554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Select the Text Tool and draw a dynamic text field near your objects. This will show the duration so place it appropriately. Give it the instance name of dur_txt&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SpiWe1ZGXnI/AAAAAAAAARM/wzatdz7WLpE/s1600-h/b4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 145px; height: 59px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SpiWe1ZGXnI/AAAAAAAAARM/wzatdz7WLpE/s400/b4.bmp" alt="" id="BLOGGER_PHOTO_ID_5375211611739283058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;5. now on the bottom most layer above your buttons draw a thin rectangle of length 350 and again make a note of its x and y coordinates. here they are 108 and 357.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SpiWebIPCgI/AAAAAAAAARE/H5oh2t3s6iY/s1600-h/b5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 64px;" src="http://3.bp.blogspot.com/_s6gSPX95als/SpiWebIPCgI/AAAAAAAAARE/H5oh2t3s6iY/s400/b5.bmp" alt="" id="BLOGGER_PHOTO_ID_5375211604689226242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Hit &lt;b&gt;Ctrl+F8&lt;/b&gt; again and this time give the name playSeek_mc. Follow the steps as in the volume controller but this time the instance name would be playSeek_mc and the x and y coordinates will be 108 and 360 resp;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SpiWeF77zYI/AAAAAAAAAQ8/VVrqO390mx4/s1600-h/b5_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 376px; height: 56px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SpiWeF77zYI/AAAAAAAAAQ8/VVrqO390mx4/s400/b5_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5375211599000489346" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;6. Now get your .flv file and save it in the same folder as this .swf file and name it myFLV.flv or whatever you want.&lt;br /&gt;7. That done select the first frame of the Actions layer and copy and paste the following code&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*------------------------Video Playback-----------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; import flash.net.NetConnection&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event.ENTER_FRAME&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,trackDuration);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*several objects have to be declared*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; videoConnection:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;NetConnection = new NetConnection&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;videoConnection.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;connect&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;null&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; videoStream:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;NetStream&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new NetStream&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(videoConnection);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; video:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Video&lt;/span&gt;&lt;span style="font-style: italic;"&gt; =&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; new Video&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; obj:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Object&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Object&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; vDuration=0;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*will contain the total duration of the video*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*onMData function called if metadata is detected. Metadata is encoded into&lt;br /&gt;  the video by the encoding software*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;obj.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;onMetaData&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = onMData;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;client&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = obj;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*Set the dimensions and position of the video*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;video.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=75;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;video.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=20&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;video.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;width&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=400;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;video.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;height&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=300;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(video);&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*actually add the video*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*all operations will be on the videoStream object*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;video.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;attachNetStream&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(videoStream);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;function  onMData(obj:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Object&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*Calculate the total duration of the video*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   vDuration=obj.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;duration&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*denotes whether timeline seekhead is being dragged*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; isDragging=0;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*show the duration on stage*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  trackDuration(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*videoStream.time give the duration already played*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   dur_txt.text=videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;time.toString&lt;/span&gt;&lt;span style="font-style: italic;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                   +" / "+vDuration;&lt;/span&gt;&lt;br /&gt;         &lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*if seek head not being dragged.This actually helps in smooth dragging&lt;br /&gt;      remove this line to see what happens when you drag without this*/&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(isDragging==0)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*advance the seek head according to duration played&lt;br /&gt;      180 is the start position of the seekhead and 350 is&lt;br /&gt;      the total lentgh it can be dragged    */&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       playSeek_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 108+(350*videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;time&lt;/span&gt;&lt;span style="font-style: italic;"&gt;/vDuration);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; isPlaying=0;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*denotes if the video is playing*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; isPaused=0;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if video is paused*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;play_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.CLICK&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,playHandler);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;stop_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.CLICK&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,stopHandler);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;pause_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.CLICK&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,pauseHandler);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if play button is clicked*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  playHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(isPlaying==0)&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if not already playing*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       videoStream&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;.play&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"myFLV.flv"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*start playing from the beginning*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       isPlaying=1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   }&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(isPaused==1)&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if paused*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;resume&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*resume playing*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       isPaused=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.visible&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;false&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*hide the play button*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if pause button is clicked*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  pauseHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;pause&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*pause play*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   isPaused=1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   play_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;visible&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*show play button*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*if stop button is clicked*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  stopHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;close&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*stop playing by closing the stream*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   isPlaying=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   play_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;visible=true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*show play button*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-------------------------------------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*------------------------Volume Control-----------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*denotes the rectangle boundary in which the volume controller can be dragged&lt;br /&gt;  parameters are x,y, width, height. Height=0 since only horizontal movement&lt;br /&gt;  is required*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var &lt;/span&gt;&lt;span style="font-style: italic;"&gt;rect:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Rectangle = new Rectangle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(240,385,100,0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*--define mouse event handlers for the sliding control---*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   slider_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_DOWN&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,dragStart);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*notice that the handling function in the following two listeners are the same*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   slider_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.MOUSE_UP&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,dragStop);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   slider_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.MOUSE_OUT&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,dragStop);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   slider_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(Event.ENTER_FRAME&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,adjustVolume);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*------------------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;         &lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*enable dragging if mouse button pressed on it*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  dragStart(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   slider_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;startDrag&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,rect);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*stop dragging if moue button released or pointer moved away*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; dragStop(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       slider_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;stopDrag&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  adjustVolume(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*calculate the volume. 240 is the minimum position and&lt;br /&gt;  100 is the width of the drag boundary rectangle "rect"*/&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; vol=(slider_mc.x-240)/100;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; volChange:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;SoundTransform = new SoundTransform&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(vol);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*assign the new volume*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;soundTransform&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = volChange;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*--------------------------------------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-------------------Timeline Seeking--------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*define mouse event handlers on the timeline seek head*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;playSeek_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.MOUSE_DOWN&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,playDragStart);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;playSeek_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener(MouseEvent.MOUSE_UP&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,playDragStop);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*denotes the rectangle boundary in which the timeline seek head can be dragged&lt;br /&gt;  parameters are x,y, width, height. Height=0 since only horizontal movement&lt;br /&gt;  is required*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; rect1:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Rectangle = new Rectangle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(108,360,350,0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*enable dragging if mouse button pressed on it*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  playDragStart(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;   &lt;span style="font-style: italic;color:gray;" &gt;/*drag only if video is playing and is not paused*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(isPlaying==1&amp;amp;&amp;amp;isPaused==0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           playSeek_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;startDrag&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,rect1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           isDragging=1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*stop dragging if moue button released from it*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; playDragStop(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       playSeek_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;stopDrag&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       isDragging=0;&lt;/span&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*determine the position of the seeh head. 108 is the minimum position&lt;br /&gt;          350 is the width of the drag  boundary rectangle rect1*/&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; seekHead=(playSeek_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-108)*vDuration/350;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style: italic;color:gray;" &gt;/*start playing from the position denoted by the seek head*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       videoStream.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;seek&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(seekHead);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-----------------------------------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now hit &lt;b&gt;Ctrl+Enter&lt;/b&gt; and test your movie.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SpiWdouVTLI/AAAAAAAAAQ0/gOxTFLzp1NA/s1600-h/b8.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 323px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SpiWdouVTLI/AAAAAAAAAQ0/gOxTFLzp1NA/s400/b8.bmp" alt="" id="BLOGGER_PHOTO_ID_5375211591158811826" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;                                                                            &lt;span style="color: rgb(204, 0, 0);font-size:130%;" &gt;      \m/\m/\m/\m/&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-3383285220491441763?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/3383285220491441763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/create-your-own-flv-video-player-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3383285220491441763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3383285220491441763'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/create-your-own-flv-video-player-with.html' title='Create your own .flv Video Player with Timeline Seek Playhead'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_s6gSPX95als/SpiVupHoFuI/AAAAAAAAAQM/uapF3_oEAm4/s72-c/b2.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-6083009211845403942</id><published>2009-08-27T22:23:00.000+05:30</published><updated>2009-08-27T22:57:22.573+05:30</updated><title type='text'>Make a Custom Cursor and Draw with the Mouse in Actionscript 3</title><content type='html'>We'll make a custom cursor which will replace the mouse pointer and we will also be able to draw with it&lt;br /&gt;1. First we'll draw the cursor. You can make it to look like anything you want. This is how my cursor looks like&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Spa86sQWXMI/AAAAAAAAAOM/y2r_RQqmfRk/s1600-h/b1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 131px; height: 141px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Spa86sQWXMI/AAAAAAAAAOM/y2r_RQqmfRk/s400/b1.bmp" alt="" id="BLOGGER_PHOTO_ID_5374690921811434690" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;To draw it first select the Rectangle Tool and select Fill Color of #CC0033 and no stroke color. Now draw a small rectangle of width 50 and height 25;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Spa87MUfkKI/AAAAAAAAAOU/irqtqO_Gtfw/s1600-h/b1_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 57px; height: 33px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Spa87MUfkKI/AAAAAAAAAOU/irqtqO_Gtfw/s400/b1_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5374690930418749602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now click outside the rectangle and approach the bottom right corner of the rectangle with the mouse pointer. When an inverted L sign appears press down on the mouse button and drag the corner upwards halfway through the side&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Spa87iQG7MI/AAAAAAAAAOc/OpwaUsZno1Y/s1600-h/b1_3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 62px; height: 36px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Spa87iQG7MI/AAAAAAAAAOc/OpwaUsZno1Y/s400/b1_3.bmp" alt="" id="BLOGGER_PHOTO_ID_5374690936305937602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;do that on both sides to get the triangle. &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Spa88FxnIkI/AAAAAAAAAOk/ykjjZNoo1n0/s1600-h/b1_4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 73px; height: 45px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Spa88FxnIkI/AAAAAAAAAOk/ykjjZNoo1n0/s400/b1_4.bmp" alt="" id="BLOGGER_PHOTO_ID_5374690945841701442" border="0" /&gt;&lt;/a&gt;Now similarly drag the left vertical side inwards th get something like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Spa88tBy5dI/AAAAAAAAAOs/9q3wonFwaWI/s1600-h/b1_5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 58px; height: 35px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Spa88tBy5dI/AAAAAAAAAOs/9q3wonFwaWI/s400/b1_5.bmp" alt="" id="BLOGGER_PHOTO_ID_5374690956378564050" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Select the shape and hit&lt;b&gt;F8&lt;/b&gt; and save it as a MovieClip Symbol with the name cursor_mc. Go to the properties panel and give it the instance name of cursor_mc.&lt;br /&gt;Double Click on the shape o edit it and select the shape inside.&lt;b&gt;Select Free Transform Tool(Q)&lt;/b&gt; and rotate it so that it looks like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Spa9ay2YA6I/AAAAAAAAAPU/UJW7sxCa6RE/s1600-h/b1_5_5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 56px; height: 55px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Spa9ay2YA6I/AAAAAAAAAPU/UJW7sxCa6RE/s400/b1_5_5.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691473337353122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Spa9akyQQEI/AAAAAAAAAPM/wtVERuDYCfo/s1600-h/b1_6.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 57px; height: 56px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Spa9akyQQEI/AAAAAAAAAPM/wtVERuDYCfo/s400/b1_6.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691469561970754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now select it and hit Ctrl+C to copy it. Create a new layer drag it below the original layer and hit Ctrl+V to paste it. Now go to the Color window and change the fill color to #4B0101 and then go to the Transform window and change the size in both the horizontal and vertical directions to 125.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Spa9aJUjYPI/AAAAAAAAAPE/JRTqclMF6DA/s1600-h/b1_7.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 208px; height: 62px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Spa9aJUjYPI/AAAAAAAAAPE/JRTqclMF6DA/s400/b1_7.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691462189637874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Your stage should look like this.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Spa9Zl_sMrI/AAAAAAAAAO8/cDc16zwRrRc/s1600-h/b1_8.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 180px; height: 99px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Spa9Zl_sMrI/AAAAAAAAAO8/cDc16zwRrRc/s400/b1_8.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691452706894514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Select select both shapes and go to the Align window and click on the following buttons circled in red.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Spa9ZFj_OJI/AAAAAAAAAO0/gcERwKqgtnE/s1600-h/b1_9.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 219px; height: 143px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Spa9ZFj_OJI/AAAAAAAAAO0/gcERwKqgtnE/s400/b1_9.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691444000766098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Your shapes should look like this&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Spa908qLF-I/AAAAAAAAAPc/Av3Q5bAZKlw/s1600-h/b1_10.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 82px; height: 74px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Spa908qLF-I/AAAAAAAAAPc/Av3Q5bAZKlw/s400/b1_10.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691922647128034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now manually arrange them to like&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Spa91NoNDpI/AAAAAAAAAPk/53EhW7XpcYE/s1600-h/b1_11.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 81px; height: 70px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Spa91NoNDpI/AAAAAAAAAPk/53EhW7XpcYE/s400/b1_11.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691927202270866" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Make a note of the centre of the MovieClip denoted be the small cross sign because your pointer will actually be that point. So for my arrow shaped cursor the centre should be just inside the arrow point.&lt;br /&gt;Now return to the main Stage. Create a new layer and rename it as Actions. Select the first frame and hit F9 to open the Actions window.&lt;br /&gt;Copy and paste the following code. Hope the documentation is sufficient&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event.ENTER_FRAME&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,followMouse);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_DOWN&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseDownHandler);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_UP&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseUpHandler);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-------------------CUSTOM CURSOR-------------------*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  followMouse(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Mouse.hide&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*hide the mouse*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*follow the mouse coordinates*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;cursor_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;mouseX&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;cursor_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;mouseY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-----------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*------------------DRAWING----------------------*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*draw only if the mouse button is pressed and the mouse is moving*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  mouseDownHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_MOVE&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseDMoveHandler);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*lineStyle(thickness,color,alpha)*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; graphics.lineStyle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(5,0x00CC77,1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*move to the point with given coordinates*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; graphics.moveTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;mouseX,mouseY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mouseDMoveHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*draw a line to the given coordinates from the coordinates in "moveTo"*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;graphics.lineTo&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;mouseX,mouseY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mouseUpHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*to stop drawing when the mouse is up line thickness&lt;br /&gt;and alpha changed to zero.Technically the line is still being drawn&lt;br /&gt;but with 0 thickness and alpha so it's not visible*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; graphics.lineStyle&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(0,0x00CC77,0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;color:gray;" &gt;/*-----------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now hit Ctrl+Enter to test your movie. To draw press and hold the left mouse button and drag it just as in any image editing software. There may be some problem if you move the mouse very fast but other than that you can draw anything&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Spa91ol7PAI/AAAAAAAAAPs/cC-8RWVCw5c/s1600-h/b5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 260px; height: 270px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Spa91ol7PAI/AAAAAAAAAPs/cC-8RWVCw5c/s400/b5.bmp" alt="" id="BLOGGER_PHOTO_ID_5374691934440471554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Pardon my drawing but enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-6083009211845403942?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/6083009211845403942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/make-custom-cursor-and-draw-with-mouse.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/6083009211845403942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/6083009211845403942'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/make-custom-cursor-and-draw-with-mouse.html' title='Make a Custom Cursor and Draw with the Mouse in Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_s6gSPX95als/Spa86sQWXMI/AAAAAAAAAOM/y2r_RQqmfRk/s72-c/b1.bmp' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-7197116171846897816</id><published>2009-08-26T18:51:00.006+05:30</published><updated>2011-06-28T23:48:01.728+05:30</updated><title type='text'>XML Driven Advanced Horizintal Dropdown Menu with Tween effects in Actionscript 3</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;/div&gt;Visit this link to see the menu in action -:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.fileden.com/files/2009/9/5/2565234/menu1.swf"&gt;http://www.fileden.com/files/2009/9/5/2565234/menu1.swf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;First the contents of the menu must be put down in a XML file in the following format.&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_s6gSPX95als/SpU5LLE2fJI/AAAAAAAAAOE/FUjjTiViqM4/s1600-h/b0.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5374264594451037330" src="http://2.bp.blogspot.com/_s6gSPX95als/SpU5LLE2fJI/AAAAAAAAAOE/FUjjTiViqM4/s400/b0.bmp" style="cursor: pointer; display: block; height: 397px; margin: 0px auto 10px; text-align: center; width: 335px;" /&gt;&lt;/a&gt;&lt;br /&gt;Each "main" tag gives the name of a main menu button in the "tag" tag and each "sub" tag gives the label of the sub menu buttons under it.&lt;br /&gt;Let's name this file "myXML.xml". Remenber &lt;b&gt; The flash(.fla) file and the XML file must be saved in the same folder.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Now open your flash file and hit &lt;b&gt;Ctrl+J&lt;/b&gt;to bring up the Properties Panel and set the background color as Black. Click OK and hit &lt;b&gt;Ctrl+F8&lt;/b&gt; to bring up the &lt;b&gt;New Symbol&lt;/b&gt; window. Enter the name as mnMenu_mc and click on Advanced. Select &lt;b&gt;Export for Actionscript&lt;/b&gt;. Click OK.&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_s6gSPX95als/SpU4IG54H9I/AAAAAAAAAN0/-XN6_DzlS6s/s1600-h/b1.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5374263442280030162" src="http://4.bp.blogspot.com/_s6gSPX95als/SpU4IG54H9I/AAAAAAAAAN0/-XN6_DzlS6s/s400/b1.bmp" style="cursor: pointer; display: block; height: 400px; margin: 0px auto 10px; text-align: center; width: 302px;" /&gt;&lt;/a&gt;&lt;br /&gt;Select the Rectangle Primitive Tool and draw a small rectangle. This will be your Main Menu button. You can use any shape, size or color. But you have to make a not of the width of the button. Here i use a 65*20 rectangle with the fill color #0033CC. Now ceate a new layer on top of the present one and create a dynamic text field that almost fills up the button.&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_s6gSPX95als/SpU4HlWqjFI/AAAAAAAAANs/uAzvu_6R6aY/s1600-h/b2.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5374263433273969746" src="http://4.bp.blogspot.com/_s6gSPX95als/SpU4HlWqjFI/AAAAAAAAANs/uAzvu_6R6aY/s400/b2.bmp" style="cursor: pointer; display: block; height: 26px; margin: 0px auto 10px; text-align: center; width: 69px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Select the text field and go to the &lt;b&gt;Properties Panel&lt;/b&gt; and give it the instance name of text_txt. Now select both the button and the text field and open the &lt;b&gt;Align Window&lt;/b&gt; and center both the objects.&lt;br /&gt;&lt;br /&gt;Repeat the process and this time give the name as sbMenu_mc. You may choose a different shape or color if you like. The name of the text field will be the same as before.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_s6gSPX95als/SpU4HDa7cvI/AAAAAAAAANk/En4o1ZLFMyE/s1600-h/b3.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5374263424165049074" src="http://3.bp.blogspot.com/_s6gSPX95als/SpU4HDa7cvI/AAAAAAAAANk/En4o1ZLFMyE/s400/b3.bmp" style="cursor: pointer; display: block; height: 26px; margin: 0px auto 10px; text-align: center; width: 68px;" /&gt;&lt;/a&gt;&lt;br /&gt;This will be your sub menu button. Again make a note of the width of the button.&lt;br /&gt;&lt;br /&gt;Thats all the graphics you need so now we script! Select the first frame of the only layer that sould be on your stage and hit &lt;b&gt;F9&lt;/b&gt; to bring up the Actions window. Copy and paste the following code. I hope the documentation is sufficient&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;Now hit &lt;b&gt;Ctrl+Enter&lt;/b&gt; to test your movie! Mine looks something like this after i click on home but the actual coolness lies in the Tweens. Have fun!!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_s6gSPX95als/SpU4Gw4isYI/AAAAAAAAANc/e38xJ0ck9kQ/s1600-h/b4.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5374263419188982146" src="http://1.bp.blogspot.com/_s6gSPX95als/SpU4Gw4isYI/AAAAAAAAANc/e38xJ0ck9kQ/s400/b4.bmp" style="cursor: pointer; display: block; height: 25px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;&lt;/submenunum[i];j++)&gt;&lt;/menulength;&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-7197116171846897816?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/7197116171846897816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/xml-driven-advanced-horizintal-dropdown.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/7197116171846897816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/7197116171846897816'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/xml-driven-advanced-horizintal-dropdown.html' title='XML Driven Advanced Horizintal Dropdown Menu with Tween effects in Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_s6gSPX95als/SpU5LLE2fJI/AAAAAAAAAOE/FUjjTiViqM4/s72-c/b0.bmp' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-3067065971355479514</id><published>2009-08-23T12:30:00.001+05:30</published><updated>2009-09-06T13:41:35.014+05:30</updated><title type='text'>Simple MP3 Music Player with sliding volume controller in Actionscript 3</title><content type='html'>We will create a  music player that will have the following :-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;    1. Play Button.&lt;/span&gt; &lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;    2. Stop Button.&lt;/span&gt; &lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;    3. Pause Button&lt;/span&gt; &lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;    *4. Sliding Volume Controller&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The mp3 file you want to play should be in the same folder as the flash file&lt;/span&gt;. Let's assume its name is myMusic.mp3.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;1.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 153, 0);"&gt; Play Button:-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;i&gt;&lt;/span&gt; We first need to draw the button. Hit &lt;span style="font-weight: bold;"&gt;Ctrl+F8&lt;/span&gt; and name the New Symbol as "play_mc" without the quotes. You can draw it to look like anything you like. I'll draw it like this.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SpDvKRtFhEI/AAAAAAAAAME/i57iAFK4ieI/s1600-h/b1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 51px; height: 51px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SpDvKRtFhEI/AAAAAAAAAME/i57iAFK4ieI/s400/b1.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057315283240002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;If you are new to flash you might be wondering about how to draw a triangle. The easiest way is to draw a small square and then click outside it now select the &lt;span style="font-weight: bold;"&gt;Selection Tool(V)&lt;/span&gt; and move the mouse near a vertex of the square. You will notice an inverted L sign under the pointer. Press the left mouse button and drag the vertex up&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SpDvKqD3KHI/AAAAAAAAAMM/d3x-UpvyZws/s1600-h/b1_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 57px; height: 53px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SpDvKqD3KHI/AAAAAAAAAMM/d3x-UpvyZws/s400/b1_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057321821218930" border="0" /&gt;&lt;/a&gt;do it on both sides&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SpDvLL4WQII/AAAAAAAAAMU/XlnjTH1jAZo/s1600-h/b1_3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 50px; height: 43px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SpDvLL4WQII/AAAAAAAAAMU/XlnjTH1jAZo/s400/b1_3.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057330899730562" border="0" /&gt;&lt;/a&gt;and you get you triangle&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; ii&gt;&lt;/span&gt; Now drag the button on to the Stage and select it. Open the &lt;span style="font-weight: bold;"&gt;Properties Window&lt;/span&gt; and set the instance name as play_mc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;2.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-weight: bold;"&gt; Stop Button:-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;i&gt;&lt;/span&gt; Make it in the same way as before and name it as "stop_mc" without the quotes.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SpDvLcPkGOI/AAAAAAAAAMc/gpNym-JUFqs/s1600-h/b2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 48px; height: 47px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SpDvLcPkGOI/AAAAAAAAAMc/gpNym-JUFqs/s400/b2.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057335292074210" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; ii&gt;&lt;/span&gt; Drag it onto the stage and give it the instance name of "stop_mc" without the quotes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;3.&lt;/span&gt;&lt;/span&gt; &lt;span style="font-weight: bold; color: rgb(0, 153, 0);"&gt;Pause Button:-&lt;/span&gt;&lt;br /&gt;  Same as before just give the names as "pause_mc".  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SpDvL1E2hMI/AAAAAAAAAMk/uEL7RUNvrzI/s1600-h/b3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 47px; height: 46px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SpDvL1E2hMI/AAAAAAAAAMk/uEL7RUNvrzI/s400/b3.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057341958030530" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You should have the three buttons on stage and it should look like this&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SpDvw0ko_NI/AAAAAAAAAMs/jIbZfdyga2I/s1600-h/b4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 161px; height: 51px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SpDvw0ko_NI/AAAAAAAAAMs/jIbZfdyga2I/s400/b4.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057977478085842" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;4.&lt;/span&gt;&lt;/span&gt; &lt;span style="font-weight: bold; color: rgb(0, 153, 0);"&gt;Sliding Volume Controller:-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;i&gt;&lt;/span&gt; Create a new Layer and drag it below the layer that has the three buttons. Now draw a line below the buttons and then go to the properties panel to set the width as 100. Make a note of the X and Y Coordinate of that line. Here it's 215 and 265 respectively.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SpDvxUnoR4I/AAAAAAAAAM0/cVKhx0LX1fU/s1600-h/b4_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 156px; height: 83px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SpDvxUnoR4I/AAAAAAAAAM0/cVKhx0LX1fU/s400/b4_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057986080556930" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; ii&gt;&lt;/span&gt;Now select the first frame of the layer that has the three buttons. Draw a small circle which will be the actual slider. Select it and Hit &lt;span style="font-weight: bold;"&gt;F8&lt;/span&gt; and save it as slider_mc. Double click on it to edit it and centre the cicle. Return to the Main Stage and go to the properties panel and give the instance name as slider_mc and set its X and Y coordinate as 315 (215+100) and 265 respectively.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SpDvxkbQLcI/AAAAAAAAAM8/DaZvq5Eve6I/s1600-h/b4_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 126px; height: 23px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SpDvxkbQLcI/AAAAAAAAAM8/DaZvq5Eve6I/s400/b4_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5373057990323613122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now we'll make the buttons work! Create a new layer and name it Actions. Select the first frame and Hit F9 to bring up the actions Window. Copy the following piece of code:-&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; isPlaying = 0;&lt;span style="color: rgb(153, 153, 153);"&gt;//flag denotes whether the music is playing(1) or has been stopped(0)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; pos=0;&lt;span style="color: rgb(153, 153, 153);"&gt;//denotes the position in which the music was paused&lt;/span&gt;  &lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; mySound&lt;span style="color: rgb(51, 51, 255);"&gt;:Sound&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new Sound(new URLRequest&lt;/span&gt;(&lt;span style="color: rgb(0, 153, 0);"&gt;"myMusic.mp3"&lt;/span&gt;));&lt;span style="color: rgb(153, 153, 153);"&gt;//load the mp3 file&lt;/span&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*define the area in which the slider will move the arguments are X, Y, width, height*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; rect:&lt;span style="color: rgb(51, 51, 255);"&gt;Rectangle &lt;/span&gt;= &lt;span style="color: rgb(51, 51, 255);"&gt;new Rectangle&lt;/span&gt;(215,265,100,0);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*define the sound channel*/&lt;/span&gt;&lt;br /&gt;var myChannel:&lt;span style="color: rgb(51, 51, 255);"&gt;SoundChannel&lt;/span&gt;=&lt;span style="color: rgb(51, 51, 255);"&gt;new SoundChannel&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*define mouse event listners for the buttons and the slider*/&lt;/span&gt;&lt;br /&gt;play_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;.&lt;span style="color: rgb(51, 51, 255);"&gt;CLICK&lt;/span&gt;,playMusic);&lt;br /&gt;stop_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;.&lt;span style="color: rgb(51, 51, 255);"&gt;CLICK&lt;/span&gt;,stopMusic);&lt;br /&gt;pause_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;.&lt;span style="color: rgb(51, 51, 255);"&gt;CLICK&lt;/span&gt;,pauseMusic);&lt;br /&gt;slider_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;.&lt;span style="color: rgb(51, 51, 255);"&gt;MOUSE_DOWN&lt;/span&gt;,dragStart);&lt;br /&gt;slider_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;.&lt;span style="color: rgb(51, 51, 255);"&gt;MOUSE_UP&lt;/span&gt;,dragStop);&lt;br /&gt;slider_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;.&lt;span style="color: rgb(51, 51, 255);"&gt;MOUSE_OUT&lt;/span&gt;,dragStop);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*the slider will invoke the "adjustVolume" function*/&lt;/span&gt;&lt;br /&gt;slider_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;addEventListener&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;Event.ENTER_FRAME&lt;/span&gt;,adjustVolume);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*PLAY BUTTON*/&lt;/span&gt;&lt;br /&gt;function  playMusic(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;if&lt;/span&gt;(isPlaying==0)&lt;br /&gt;myChannel=mySound.&lt;span style="color: rgb(51, 51, 255);"&gt;play&lt;/span&gt;();&lt;br /&gt;isPlaying=1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*--------------STOP BUTTON--------------*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  stopMusic(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;if(isPlaying==1)&lt;br /&gt;myChannel.&lt;span style="color: rgb(51, 51, 255);"&gt;stop&lt;/span&gt;();&lt;br /&gt;isPlaying=0;&lt;br /&gt;pos=0;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:gray;"&gt;/*----------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*--------------PAUSE BUTTON--------------*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  pauseMusic(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;&lt;span style="color:gray;"&gt;/*if music is playing*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;if&lt;/span&gt;(isPlaying==1)&lt;br /&gt;{&lt;br /&gt;pos=myChannel.position;&lt;span style="color: rgb(153, 153, 153);"&gt;//record position&lt;/span&gt;&lt;br /&gt;myChannel.stop();&lt;br /&gt;isPlaying=0;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:gray;"&gt;/*if music is paused*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; else&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;isPlaying=1;&lt;br /&gt;myChannel=mySound.play(pos);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:gray;"&gt;/*----------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:gray;"&gt;/*--------------SLIDING CONTROLLER--------------*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  dragStart(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;) {&lt;br /&gt;slider_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;startDrag&lt;/span&gt;(&lt;span style="color: rgb(51, 51, 255);"&gt;true&lt;/span&gt;,rect);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt; dragStop(e:&lt;span style="color: rgb(51, 51, 255);"&gt;MouseEvent&lt;/span&gt;){&lt;br /&gt;slider_mc.&lt;span style="color: rgb(51, 51, 255);"&gt;stopDrag&lt;/span&gt;();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;function&lt;/span&gt;  adjustVolume(e:&lt;span style="color: rgb(51, 51, 255);"&gt;Event&lt;/span&gt;) {&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; var&lt;/span&gt; vol=(slider_mc.x-215)/100;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;var&lt;/span&gt; volChange:&lt;span style="color: rgb(51, 51, 255);"&gt;SoundTransform&lt;/span&gt; = &lt;span style="color: rgb(51, 51, 255);"&gt;new SoundTransform&lt;/span&gt;(vol);&lt;br /&gt;myChannel.&lt;span style="color: rgb(51, 51, 255);"&gt;soundTransform&lt;/span&gt; = volChange;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:gray;"&gt;/*----------------------------------------*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That's it. Hit Ctrl+Enter to check your own Music Player!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-3067065971355479514?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/3067065971355479514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/simple-mp3-music-player-with-sliding.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3067065971355479514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3067065971355479514'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/simple-mp3-music-player-with-sliding.html' title='Simple MP3 Music Player with sliding volume controller in Actionscript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_s6gSPX95als/SpDvKRtFhEI/AAAAAAAAAME/i57iAFK4ieI/s72-c/b1.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-5138457887025359699</id><published>2009-08-22T17:00:00.000+05:30</published><updated>2009-08-22T17:33:10.020+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Action Script 3'/><category scheme='http://www.blogger.com/atom/ns#' term='Tween Class'/><title type='text'>The Tween Class in ActionScript 3</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Today we'll learn about the &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);font-size:130%;" &gt;Tween class&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt; and apply it to a practical example.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;1.&lt;/span&gt;&lt;/span&gt;    Open a new flash file. Hit &lt;span style="font-weight: bold;"&gt;Ctrl+J&lt;/span&gt; to bring up the Document Properties and change the background color to black.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/So_cK3OfxeI/AAAAAAAAAKQ/mwnEoQQaplk/s1600-h/b1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 226px;" src="http://4.bp.blogspot.com/_s6gSPX95als/So_cK3OfxeI/AAAAAAAAAKQ/mwnEoQQaplk/s400/b1.bmp" alt="" id="BLOGGER_PHOTO_ID_5372754959657846242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;2. &lt;/span&gt;   Then press &lt;span style="font-weight: bold;"&gt;Ctrl+F8&lt;/span&gt; to open the New Symbol window and name it as btn1_mc. We will make a button. Now select the  &lt;span style="font-weight: bold;"&gt;Rectangle Tool(R) &lt;/span&gt;and change the Stroke color to &lt;span style="color: rgb(153, 51, 0); font-weight: bold;"&gt;#0066CC&lt;/span&gt; and the fill color to &lt;span style="color: rgb(153, 51, 0); font-weight: bold;"&gt;#0099CC&lt;/span&gt;. You can use any other color.&lt;br /&gt;Go to the Properties Panel and set the stroke thickness as 4.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/So_cLLehddI/AAAAAAAAAKY/wWG-zt4EumY/s1600-h/b2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 286px; height: 219px;" src="http://3.bp.blogspot.com/_s6gSPX95als/So_cLLehddI/AAAAAAAAAKY/wWG-zt4EumY/s400/b2.bmp" alt="" id="BLOGGER_PHOTO_ID_5372754965093774802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;3.&lt;/span&gt;&lt;/span&gt;  Draw a rectangle of the size you want you button to be. A width of 120 and a height of 40 should suffice. After drawing, select the rectangle and go to the align panel and centre the rectangle.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/So_cLiTKBLI/AAAAAAAAAKg/j89Neh9I_Og/s1600-h/b3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 234px; height: 121px;" src="http://2.bp.blogspot.com/_s6gSPX95als/So_cLiTKBLI/AAAAAAAAAKg/j89Neh9I_Og/s400/b3.bmp" alt="" id="BLOGGER_PHOTO_ID_5372754971220116658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;4.&lt;/span&gt;&lt;/span&gt; Create a new layer&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/So_cMFrVSwI/AAAAAAAAAKo/87db_1I3600/s1600-h/b4_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 203px; height: 115px;" src="http://3.bp.blogspot.com/_s6gSPX95als/So_cMFrVSwI/AAAAAAAAAKo/87db_1I3600/s400/b4_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5372754980716759810" border="0" /&gt;&lt;/a&gt;and select the &lt;span style="font-weight: bold;"&gt;Text Tool(T)&lt;/span&gt; and create a label for your button. I will name it "HOME". Go to the &lt;span style="font-weight: bold;"&gt;Align Panel&lt;/span&gt; and centre the text box too.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/So_cMW0M6HI/AAAAAAAAAKw/aX2cRYUFyrY/s1600-h/b4_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 152px; height: 69px;" src="http://3.bp.blogspot.com/_s6gSPX95als/So_cMW0M6HI/AAAAAAAAAKw/aX2cRYUFyrY/s400/b4_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5372754985317361778" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;5.&lt;/span&gt;&lt;/span&gt; Now Click on &lt;span style="font-weight: bold;"&gt;Scene1&lt;/span&gt; to return to the Stage.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/So_dFUJd9ZI/AAAAAAAAAK4/Dl8FPnLD2s8/s1600-h/b5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 169px; height: 48px;" src="http://4.bp.blogspot.com/_s6gSPX95als/So_dFUJd9ZI/AAAAAAAAAK4/Dl8FPnLD2s8/s400/b5.bmp" alt="" id="BLOGGER_PHOTO_ID_5372755963853796754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;6.&lt;/span&gt;&lt;/span&gt; Go to &lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Window-&gt;Library&lt;/span&gt; and you will see the btn1_mc movie clip. Right Click on it and create two duplicates and name them btn1_mc and btn3_mc respectively. Change the color and the text labels on the duplicate if you want to. I will name them "Gallery" and "About Us".  &lt;span style="color: rgb(51, 51, 153);"&gt;Changing the color will help us understand a particular issue we'll address later.&lt;/span&gt;&lt;br /&gt;Now drag each button onto the stage and arrange them somewhat like this&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/So_dFuu83PI/AAAAAAAAALA/RDwQkSDuv-U/s1600-h/b6.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 106px;" src="http://4.bp.blogspot.com/_s6gSPX95als/So_dFuu83PI/AAAAAAAAALA/RDwQkSDuv-U/s400/b6.bmp" alt="" id="BLOGGER_PHOTO_ID_5372755970990333170" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;7. &lt;/span&gt;&lt;/span&gt;Select each button and go to the &lt;span style="font-weight: bold;"&gt;Properties Panel&lt;/span&gt; button and give them instance name as btn1_mc, btn2_mc and btn3_mc&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;8&lt;/span&gt;.  Create a new layer, name it Actions and select the first frame and hit &lt;span style="font-weight: bold;"&gt;F9&lt;/span&gt; to bring up the Actions window. We are ready to write the script.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;9. &lt;/span&gt;To script tweens we first need to import the Tween Class like so -&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; import fl.transitions.Tween&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt; &lt;span style="font-style: italic;"&gt;       &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; import fl.transitions.easing.*&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we'll implement the tween so that the button changes size when we &lt;span style="font-style: italic;"&gt;RollOver&lt;/span&gt; and return back when we &lt;span style="font-style: italic;"&gt;RollOut&lt;/span&gt; therefore for each button we must add &lt;span style="font-style: italic;"&gt;RollOver&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;RollOut&lt;/span&gt; listeners.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        btn1_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_OVER&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseOverHandler);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;        btn1_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_OUT&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseOutHandler);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;    &lt;/span&gt; &lt;span style="font-style: italic;"&gt;        btn2_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_OVER&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseOverHandler);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;        btn2_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_OUT&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseOutHandler);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;        &lt;/span&gt; &lt;span style="font-style: italic;"&gt;        btn3_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_OVER&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseOverHandler);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;        btn3_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent.MOUSE_OUT&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseOutHandler);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These listeners will invoke the "mouseOverHandler" function on the RollOver Event and the "mouseOutHandler" function on the RollOut Event&lt;br /&gt;Now we will define the two functions&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mouseOverHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt; &lt;span style="font-style: italic;"&gt;            e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=.8;//altering alpha makes the change more prominent&lt;/span&gt; &lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Tween&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"scaleX"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Elastic.easeOut&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleX&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,1.25,1,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Tween&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,"&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;scaleY"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Elastic.easeOut&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,1.25,1,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;        }&lt;/span&gt; &lt;span style="font-style: italic;"&gt;        &lt;/span&gt; &lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; mouseOutHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) {&lt;/span&gt; &lt;span style="font-style: italic;"&gt;            e.c&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;urrentTarget.alpha&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=1;&lt;/span&gt; &lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Tween&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"scaleX"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Elastic.easeOut&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleX&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,1,1,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Tween&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"scaleY"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Elastic.easeOut&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,1,1,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;true&lt;/span&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"e.&lt;span style="color: rgb(51, 51, 255);"&gt;currentTarget&lt;/span&gt;"&lt;/span&gt; gives the child on which the Event has occured. The arguments of the Tween function is as follows :- &lt;span style="color: rgb(153, 0, 0); font-style: italic;"&gt;1. the object, 2. the property that has to be tweened, 3. Type of tween, 4. Start value, 5. End value, 6. Duration in Seconds, 7. Use Seconds(boolean).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;10.&lt;/span&gt; if you have copied all of the code hit Ctrl+Enter to test your movie. Rollover your buttons you'll see them growing and shrinking but notice that we have a problem that is most apparent when we rollover the middle button.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/So_dF3kdYVI/AAAAAAAAALI/KJTg4ph9LXQ/s1600-h/b10_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 163px;" src="http://2.bp.blogspot.com/_s6gSPX95als/So_dF3kdYVI/AAAAAAAAALI/KJTg4ph9LXQ/s400/b10_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5372755973362245970" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The middle button grows over the first button but goes under the last button. That happens with the first button too&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/So_dGet2J6I/AAAAAAAAALQ/Zpu-gtmrW-8/s1600-h/b10_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 126px;" src="http://1.bp.blogspot.com/_s6gSPX95als/So_dGet2J6I/AAAAAAAAALQ/Zpu-gtmrW-8/s400/b10_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5372755983870601122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;11.&lt;/span&gt; As you might have guessed, to solve this problem we have to change the depth of the button and bring it to the topmost layer. To do that add the following line of code to the "mouseOverHandler" function.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; setChildIndex&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget.name&lt;/span&gt;&lt;span style="font-style: italic;"&gt;),&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;numChildren&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-1);&lt;/span&gt; &lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;"&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;numChildren&lt;/span&gt;" give the total number of children present. Thus by setting the index to "&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;numChildren&lt;/span&gt;-1" we actually swap the depths of the present child with that of the topmost child.&lt;br /&gt;Hit &lt;span style="font-weight: bold;"&gt;Ctrl+Enter&lt;/span&gt; to test you movie. The problem is solved!!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/So_dGmiLXwI/AAAAAAAAALY/VXR8S4SKlII/s1600-h/b11_1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 146px;" src="http://3.bp.blogspot.com/_s6gSPX95als/So_dGmiLXwI/AAAAAAAAALY/VXR8S4SKlII/s400/b11_1.bmp" alt="" id="BLOGGER_PHOTO_ID_5372755985969143554" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/So_d8eDmZDI/AAAAAAAAALg/XROb3wpcN6c/s1600-h/b11_2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 101px;" src="http://1.bp.blogspot.com/_s6gSPX95als/So_d8eDmZDI/AAAAAAAAALg/XROb3wpcN6c/s400/b11_2.bmp" alt="" id="BLOGGER_PHOTO_ID_5372756911406343218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So there you have it. The buttons look really good with the Tween. You can choose different kind of tweens. Instead of the &lt;span style="color: rgb(51, 51, 255);"&gt;Elastic&lt;/span&gt; easing used here you can choose from &lt;span style="color: rgb(51, 51, 255);"&gt;Back, Bounce, None, Regular, Strong &lt;/span&gt;and instead of &lt;span style="color: rgb(51, 51, 255);"&gt;easeOut&lt;/span&gt; you can use&lt;span style="color: rgb(51, 51, 255);"&gt; easeIn &lt;span style="color: rgb(0, 0, 0);"&gt;or&lt;/span&gt; easeInOut&lt;/span&gt;. Select the tween that suits your application the best.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-5138457887025359699?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/5138457887025359699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/tween-class-in-actionscript-3.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5138457887025359699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5138457887025359699'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/tween-class-in-actionscript-3.html' title='The Tween Class in ActionScript 3'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_s6gSPX95als/So_cK3OfxeI/AAAAAAAAAKQ/mwnEoQQaplk/s72-c/b1.bmp' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-3305732462998298133</id><published>2009-08-20T09:50:00.000+05:30</published><updated>2009-08-28T18:13:44.708+05:30</updated><title type='text'>XML Driven Dynamic Photo Gallery</title><content type='html'>We will use a XML file to list all the images and the .swf file will dynamically load the images.&lt;br /&gt;&lt;br /&gt;In the directory where you have saved the flash file create another folder and lets name it gallery. suppose we have 20 images name as 1.jpg, 2.jpg, ..., 20.jpg. To list the these in the XML file open your text editor and type the following.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SozTQ5AwJ7I/AAAAAAAAAKI/B9Y2nN1EmQE/s1600-h/b.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 336px;" src="http://2.bp.blogspot.com/_s6gSPX95als/SozTQ5AwJ7I/AAAAAAAAAKI/B9Y2nN1EmQE/s400/b.bmp" alt="" id="BLOGGER_PHOTO_ID_5371900742681503666" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Save it as images.xml in the gallery folder. Edit the XML file if you change the name of the folder or that of the images. Now in the flash file select the first frame and hit f9 to bring up the Actions window. Then Copy and Paste the following code. I hope the documentation is enough.&lt;br /&gt;                     &lt;br /&gt;                     &lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; xmlLoader:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;URLLoader&lt;/span&gt;&lt;span style="font-style: italic;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new URLLoader&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;xmlLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event.COMPLETE&lt;/span&gt;&lt;span style="font-style: italic;"&gt;, parseXML);&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//if XML file loaded successfully&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;xmlLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;IOErrorEvent.IO_ERROR&lt;/span&gt;&lt;span style="font-style: italic;"&gt;, errorOccurred);&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//if the XML file fails to load&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;xmlLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;load&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new URLRequest&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;"gallery/images.xml"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;)); &lt;/span&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//load the XML File&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//reads the XML file and invoked if the file is loaded successfully&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; parseXML(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;void&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; i:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; totalNodes:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; XMLData:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;XML&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new XML&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(xmlLoader.data);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    totalNodes= XMLData.img.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;length&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//"img" because the XML use that as a tag "&lt;img src="http://www.blogger.com/post-edit.g?blogID=8107625831108404275&amp;amp;postID=3305732462998298133" /&gt;&lt;!--[CDATA[gallery/1.jpg]]--&gt;"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; for&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (i=0; i&lt;totalnodes;&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//traversing through the XML file&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        attachImages(XMLData.img[i].toString(),i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//Outputs an error message if the XML file fails to load&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt; errorOccurred(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Event&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;void&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;trace&lt;/span&gt;&lt;span style="font-style: italic;"&gt;("Error Occured");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//attaches the images to the stage.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  attachImages(url:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;String&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,i:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;void&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; myLoader:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;Loader&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;new Loader&lt;/span&gt;&lt;span style="font-style: italic;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        myLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;load&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt; new&lt;/span&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;URLRequest&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(url) );&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//load the image&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       &lt;/span&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt; /*follwing four lines follow a static arrangement but you can create dynamic functions depending upon the  number of images. Assign your scaling according to the image size. Here I'm using 600x480 image size*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        myLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 100*(i%5)+10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        myLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt; = 100*(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;int&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(i/5))+10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        myLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleX&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0.13;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        myLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0.13;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addChild&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(myLoader);&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;//Attach the image to stage and make it visible&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/totalnodes;&gt;&lt;/span&gt;&lt;span&gt;&lt;totalnodes;&gt;Thats it press Ctrl+Enter and Voila! your images will appear as thumbnails. With trial and error decide upon the scale to use.&lt;/totalnodes;&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;totalnodes;&gt;&lt;br /&gt;&lt;/totalnodes;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we'll add a few lines of code and transfrom it to a gallery where the images can be viewed full size! The fucntionality we'll add is that if we click on the thumbnails they'll expand and fill the stage so we can properly view the image.&lt;br /&gt;Thus we'll need a listener that will wait for a mouse click. So add the following line of code to the "attachImages" function defined previously&lt;br /&gt;&lt;br /&gt;     &lt;span style="font-style: italic;"&gt;myLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;addEventListener&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;CLICK&lt;/span&gt;&lt;span style="font-style: italic;"&gt;,mouseClickHandler);&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;This will invoke the "mouseClickHandler" function when we click a thumbnail. Now we have to define that function. it will use 4 global variables so that an image can shrink back to a thumbnail &lt;b&gt;when the expanded image is clicked again&lt;/b&gt;.The flag will denote whether the image is a thumnail or is expanded. flag=0 denotes a thumbnail and flag=1 denotes that the image has been expanded.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic;"&gt; originalX,originalY,originalScaleX, originalScaleY,flag=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;function&lt;/span&gt;&lt;span style="font-style: italic;"&gt;  mouseClickHandler(e:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;MouseEvent&lt;/span&gt;&lt;span style="font-style: italic;"&gt;):&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;void&lt;/span&gt;&lt;span style="font-style: italic;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;if&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(flag==0)&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt;//satisfied if a thumbnail is clicked&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;              &lt;/span&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt;  //e.currentTarget denotes the thumbnail that has been clicked&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt;                //storing the properties of the thumbnail in the global variables&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                originalX=e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                originalY=e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                originalScaleX=e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleX&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                originalScaleY=e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;               &lt;/span&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt; //this line will bring the expanded image to the top of all other thumbnails&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;setChildIndex&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;getChildByName&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;name&lt;/span&gt;&lt;span style="font-style: italic;"&gt;),&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;numChildren&lt;/span&gt;&lt;span style="font-style: italic;"&gt;-1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt;                /*expanding the thumbnail by assigning new values to the properties. scaleX and   scaleY  properties will change according to the size of the images used and the size of the       stageHere i use 600x480 images and a default stage of 550x400*/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleX&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0.92;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=0.83;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                flag=1;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt;//image is expanded&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;else&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt;//satisfied if the expanded image is clicked&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                flag=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 153, 153); font-style: italic;"&gt;//assigning original values to the properties.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;x&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=originalX;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=originalY;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleX&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=originalScaleX;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                e.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;currentTarget&lt;/span&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;scaleY&lt;/span&gt;&lt;span style="font-style: italic;"&gt;=originalScaleY;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hit Ctrl+Enter to test the movie. Click on the thumbnails to see them expand and click on the expanded image to see them shrink again. &lt;span style="font-weight: bold; font-style: italic; color: rgb(102, 0, 0);"&gt;It is very important that you use uniform sized images&lt;/span&gt;. Otherwise you'll have to build a dynamic scaling function.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-3305732462998298133?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/3305732462998298133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/we-will-use-xml-file-to-list-all-images.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3305732462998298133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3305732462998298133'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/we-will-use-xml-file-to-list-all-images.html' title='XML Driven Dynamic Photo Gallery'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_s6gSPX95als/SozTQ5AwJ7I/AAAAAAAAAKI/B9Y2nN1EmQE/s72-c/b.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-4034013807356313032</id><published>2009-08-20T09:43:00.000+05:30</published><updated>2009-08-20T09:49:31.656+05:30</updated><title type='text'>Load an image with ActionScript(AS2 and AS3)</title><content type='html'>Create a new flash file and save it in the same folder the has the image you want to load. Let the image be named as myImage.jpg.&lt;br /&gt;Load with AS2 -&gt;&lt;br /&gt;   Copy and paste the following code:&lt;br /&gt;     &lt;br /&gt;   &lt;span style="font-weight: bold;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                       &lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic; font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;font-size:100%;" &gt;_root&lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;font-size:100%;" &gt;createEmptyMovieClip&lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;font-size:100%;" &gt;"image_mc"&lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;,&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;font-size:100%;" &gt;_root.getNextHighestDepth&lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;());&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;                         image_mc.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;font-size:100%;" &gt;loadMovie&lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;font-size:100%;" &gt;"myImage.jpg"&lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;);&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;             &lt;br /&gt;   The first line creates a movie clip instance "image_mc". _root.getHighestDepth() function returns the next highest depth such that "image_mc" is sttached on top of any other symbols that may be present on Stage. Instead of this can use numerical values such as 0, 1, 52168, etc. The second line loads the image.&lt;br /&gt;&lt;br /&gt;Load with AS3-&gt;&lt;br /&gt;   Copy and paste the following code:&lt;br /&gt; &lt;br /&gt;     &lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic; font-weight: bold;"&gt;var&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; myLoader:&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic; font-weight: bold;"&gt;Loader&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic; font-weight: bold;"&gt;new Loader&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;        myLoader.&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic; font-weight: bold;"&gt;load&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic; font-weight: bold;"&gt;new URLRequest&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic; font-weight: bold;"&gt;"myImage.jpg"&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;       &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic; font-weight: bold;"&gt; addChild&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;(myLoader);&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;   This is a lot different from AS2. Here the image is not loaded by a MovieClip instance but by an object, "myLoader", of the new Loader class . The third line actually attaches the image to the Stage. You might notice there was no such function in AS2.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-4034013807356313032?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/4034013807356313032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/load-image-with-actionscriptas2-and-as3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/4034013807356313032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/4034013807356313032'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/load-image-with-actionscriptas2-and-as3.html' title='Load an image with ActionScript(AS2 and AS3)'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-2161375197370187996</id><published>2009-08-09T20:42:00.000+05:30</published><updated>2009-08-09T21:04:31.410+05:30</updated><title type='text'>Motion Guide Tutorial</title><content type='html'>Motion Guide is a line which is the path along which you want an object to move&lt;br /&gt;I'll be using Adobe Flash CS4 from now on and start with AS3 tutorials after i learn it. If you're using an older version of Flash you can follow the tutorials just as well.&lt;br /&gt;&lt;br /&gt;1.    Create two layers and name the top one Guide and the one below it Obj. You can name them anything you want but&lt;br /&gt;you should name your layers according to what they contain. Here the Guide layer will contain the Motion Guide and the&lt;br /&gt;Obj layer will contain the object to be guided&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sn7oFRWpvwI/AAAAAAAAAIc/wGcrdIBmXqs/s1600-h/blog1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 93px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sn7oFRWpvwI/AAAAAAAAAIc/wGcrdIBmXqs/s400/blog1.bmp" alt="" id="BLOGGER_PHOTO_ID_5367982983127613186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2.    Select the first frame of the Guide layer. Select the Pencil Tool&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sn7oFm2wSGI/AAAAAAAAAIk/GaaG1WQRf0g/s1600-h/blog2.1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 111px; height: 105px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sn7oFm2wSGI/AAAAAAAAAIk/GaaG1WQRf0g/s400/blog2.1.bmp" alt="" id="BLOGGER_PHOTO_ID_5367982988899403874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;and draw the path you want the object to move on.This line will be your Motion Guide.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Sn7oGF7nOII/AAAAAAAAAIs/LeP5IszcAhc/s1600-h/blog2.2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 287px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Sn7oGF7nOII/AAAAAAAAAIs/LeP5IszcAhc/s400/blog2.2.bmp" alt="" id="BLOGGER_PHOTO_ID_5367982997241280642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;3.    Now draw your object. To do that hit Ctrl+F8 to bring up the Create New Symbol Box. Name it as obj_mc&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Sn7oGpZ_zyI/AAAAAAAAAI0/6-cBTwSQH4U/s1600-h/blog+3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 156px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Sn7oGpZ_zyI/AAAAAAAAAI0/6-cBTwSQH4U/s400/blog+3.bmp" alt="" id="BLOGGER_PHOTO_ID_5367983006763962146" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I'll draw a simple circle with the Oval Tool.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sn7oGhIMakI/AAAAAAAAAI8/AoQiHt1ORVU/s1600-h/blog+3.1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 270px; height: 148px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sn7oGhIMakI/AAAAAAAAAI8/AoQiHt1ORVU/s400/blog+3.1.bmp" alt="" id="BLOGGER_PHOTO_ID_5367983004541807170" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sn7paw2PnOI/AAAAAAAAAJE/6pwK0-MF2Aw/s1600-h/blog+3.2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 117px; height: 103px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sn7paw2PnOI/AAAAAAAAAJE/6pwK0-MF2Aw/s400/blog+3.2.bmp" alt="" id="BLOGGER_PHOTO_ID_5367984451870498018" border="0" /&gt;&lt;/a&gt;You can make the object to look like whatever you want.&lt;br /&gt;4. Right click on the Guide Layer name and select Guide. This will make the line on that layer a Motion Guide.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Sn7pbGwRRhI/AAAAAAAAAJM/qb_Y7ghoPb8/s1600-h/blog+4.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 271px; height: 400px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Sn7pbGwRRhI/AAAAAAAAAJM/qb_Y7ghoPb8/s400/blog+4.bmp" alt="" id="BLOGGER_PHOTO_ID_5367984457751021074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If You do it correctly the layers will look like this&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Sn7pbX8K0qI/AAAAAAAAAJU/y1HdKE5l_Uo/s1600-h/blog+4.1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 210px; height: 67px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Sn7pbX8K0qI/AAAAAAAAAJU/y1HdKE5l_Uo/s400/blog+4.1.bmp" alt="" id="BLOGGER_PHOTO_ID_5367984462364332706" border="0" /&gt;&lt;/a&gt;. Now pay attention. Click on the Obj Layer name&lt;br /&gt;and while pressing the mouse button make an upward motion with the mouse.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/Sn7pbtcWTEI/AAAAAAAAAJc/Ccyfq1-9PH0/s1600-h/blog+4.2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 241px; height: 128px;" src="http://1.bp.blogspot.com/_s6gSPX95als/Sn7pbtcWTEI/AAAAAAAAAJc/Ccyfq1-9PH0/s400/blog+4.2.bmp" alt="" id="BLOGGER_PHOTO_ID_5367984468136447042" border="0" /&gt;&lt;/a&gt; When you Release it your layers should look like&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/Sn7pbyymRZI/AAAAAAAAAJk/s4UnRMVvLJc/s1600-h/blog+4.3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 215px; height: 129px;" src="http://2.bp.blogspot.com/_s6gSPX95als/Sn7pbyymRZI/AAAAAAAAAJk/s4UnRMVvLJc/s400/blog+4.3.bmp" alt="" id="BLOGGER_PHOTO_ID_5367984469571945874" border="0" /&gt;&lt;/a&gt;You have assigned the Guide layer as the motion guide of the Obj Layer.&lt;br /&gt;5. In the Library window you will see your obj_mc object. If you cannot find your Library window go to Window-&gt;Library or hit Ctrl+L. Now Select the fisrt frame of the Obj Layer and drag the object from the library to the top end of the&lt;br /&gt;guide line.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sn7q6UtZ8wI/AAAAAAAAAJs/Z2oF5KAOBHg/s1600-h/blog+5.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 188px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sn7q6UtZ8wI/AAAAAAAAAJs/Z2oF5KAOBHg/s400/blog+5.bmp" alt="" id="BLOGGER_PHOTO_ID_5367986093584675586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now go to the timline and on each layer Right Click on the 30th frame and select "Insert KeyFrame". your timeline should look like this&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/Sn7q6kwhxqI/AAAAAAAAAJ0/ZgVSSr_K5kM/s1600-h/blog+5.1.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 93px;" src="http://4.bp.blogspot.com/_s6gSPX95als/Sn7q6kwhxqI/AAAAAAAAAJ0/ZgVSSr_K5kM/s400/blog+5.1.bmp" alt="" id="BLOGGER_PHOTO_ID_5367986097892738722" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now select the last frame of the Obj Layer and Drag your object to the end of Motion Guide. The little circle in the centre should snap on to the line. Now select any frame of the Obj Layer and Select "Create Classic Tween".&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/Sn7q63cPV5I/AAAAAAAAAJ8/TjdyodiKWJA/s1600-h/blog+5.2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 95px;" src="http://3.bp.blogspot.com/_s6gSPX95als/Sn7q63cPV5I/AAAAAAAAAJ8/TjdyodiKWJA/s400/blog+5.2.bmp" alt="" id="BLOGGER_PHOTO_ID_5367986102907918226" border="0" /&gt;&lt;/a&gt;You're done.&lt;br /&gt;Hit Ctrl+Enter to test the movie.&lt;br /&gt;6. If the Movie is very fast you can do two things. Firstly increase the number of frames. Here we are using 30 or you can hit Ctrl+J and in the window that pops up reduce the Frames per Second(fps) to a lower value. Default fps in CS4 if 24.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-2161375197370187996?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/2161375197370187996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/motion-guide-tutorial.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2161375197370187996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2161375197370187996'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/08/motion-guide-tutorial.html' title='Motion Guide Tutorial'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_s6gSPX95als/Sn7oFRWpvwI/AAAAAAAAAIc/wGcrdIBmXqs/s72-c/blog1.bmp' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-5788220459019369144</id><published>2009-07-26T01:48:00.000+05:30</published><updated>2009-07-26T02:06:00.346+05:30</updated><title type='text'>Load Text From an External Text File using Action Script</title><content type='html'>There are two ways you can load data from an external text file:&lt;br /&gt;1. You can load the whole text present in the file&lt;br /&gt;2. Or you can format the text so that you can load in parts if you want to.&lt;br /&gt;&lt;br /&gt;To Begin create a text file myText.txt or whatever you like and copy and paste the following text in it&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;    &lt;span style="font-weight: bold; color: rgb(0, 102, 0);"&gt;&amp;amp;monthNames=January,February,March,April,May,June,July,August,September,October,November,December&lt;/span&gt; &lt;span style="font-weight: bold; color: rgb(0, 102, 0);"&gt;&amp;amp;dayNames=Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday&lt;/span&gt; &lt;/div&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;"&amp;amp;monthNames" and "&amp;amp;dayNames" are the labels which will help us to acess a part of the data. You can name&lt;br /&gt;them in any way you like such as "&amp;amp;part", "&amp;amp;xxx" or "&amp;amp;whatEverILike". All the parts you would like to access&lt;br /&gt;should have a different label.&lt;br /&gt;&lt;br /&gt;Now create a file loadText.fla and save it in the SAME FOLDER as the text file.Create a second layer and name&lt;br /&gt;it "Action". Select the first layer and click on the Text Tool and go to properties panel and set the Text Type&lt;br /&gt;as Dynamic Text and select the Line Type as Multiline then create three text fields.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SmtqHh_IWXI/AAAAAAAAAIE/O2EfW8dhJDU/s1600-h/blog1.2.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 163px; height: 124px;" src="http://4.bp.blogspot.com/_s6gSPX95als/SmtqHh_IWXI/AAAAAAAAAIE/O2EfW8dhJDU/s320/blog1.2.bmp" alt="" id="BLOGGER_PHOTO_ID_5362496458929494386" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Select each one at a time and give their instance name in the&lt;br /&gt;Properties Panel as monthnames_txt, daynames_txt and alltext_txt respectively. Create small Satitc Text boxes on top&lt;br /&gt;of each previous text boxes and create labels. At the end of these steps your stage should look somewhat like this.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SmtsOm8fg4I/AAAAAAAAAIM/OlWAPBqze8c/s1600-h/blog2.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 237px;" src="http://3.bp.blogspot.com/_s6gSPX95als/SmtsOm8fg4I/AAAAAAAAAIM/OlWAPBqze8c/s320/blog2.bmp" alt="" id="BLOGGER_PHOTO_ID_5362498779542946690" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;That done right click on the first frame of the Action layer and select Actions&lt;br /&gt;In the window that opens copy and paste the following script. I think it's sufficiently documented.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;//declare two objects of the LoadVars class to load the text file&lt;/span&gt;&lt;br /&gt;var text_lv:LoadVars = new LoadVars();&lt;br /&gt;var text1_lv:LoadVars = new LoadVars();&lt;br /&gt;&lt;br /&gt;text_lv.load("myText.txt");&lt;span style="color: rgb(102, 102, 102);"&gt;//load file to display in parts&lt;/span&gt;&lt;br /&gt;text1_lv.load("myText.txt");&lt;span style="color: rgb(102, 102, 102);"&gt;//load file to display the whole text&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;span style="color: rgb(102, 102, 102);"&gt; //display the text in parts&lt;/span&gt;&lt;br /&gt;text_lv.onLoad = function (success:Boolean)&lt;br /&gt;{&lt;br /&gt;  if (success)&lt;br /&gt;  {&lt;br /&gt;      monthnames_txt.text =text_lv.monthNames;&lt;span style="color: rgb(102, 102, 102);"&gt;//show text labelled as "&amp;amp;monthnames"&lt;/span&gt;&lt;br /&gt;      daynames_txt.text =text_lv.dayNames;&lt;span style="color: rgb(102, 102, 102);"&gt;//show text labelled as "&amp;amp;daynames"&lt;/span&gt;&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;  {&lt;br /&gt;      monthnames_txt.text = " Cannot Open File ";&lt;span style="color: rgb(102, 102, 102);"&gt;//error message&lt;/span&gt;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;//display the whole text&lt;/span&gt;&lt;br /&gt;text1_lv.onData = function  (myText:String)&lt;br /&gt;{&lt;br /&gt;  alltext_txt.text = myText;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That's it! Hit Ctrl+Enter to test. If the text is not visible make sure the color of the text fields is not the&lt;br /&gt;same as the background color, also check that you have saved the flash file and the text file in the same folder.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_s6gSPX95als/SmtsPCOfFVI/AAAAAAAAAIU/f3ZeKKsha8U/s1600-h/blog3.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 258px;" src="http://1.bp.blogspot.com/_s6gSPX95als/SmtsPCOfFVI/AAAAAAAAAIU/f3ZeKKsha8U/s320/blog3.bmp" alt="" id="BLOGGER_PHOTO_ID_5362498786866173266" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-5788220459019369144?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/5788220459019369144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/07/load-text-from-external-text-file-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5788220459019369144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/5788220459019369144'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/07/load-text-from-external-text-file-using.html' title='Load Text From an External Text File using Action Script'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_s6gSPX95als/SmtqHh_IWXI/AAAAAAAAAIE/O2EfW8dhJDU/s72-c/blog1.2.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-3483113499491446912</id><published>2009-02-18T23:22:00.001+05:30</published><updated>2009-02-18T23:45:02.246+05:30</updated><title type='text'>Flash Analog Clock Tutorials</title><content type='html'>&lt;div style="text-align: center;"&gt;Open a new file and save it as clock.fla. Rename the first layer as bg and go to Windows -&gt; Color Mixer and set it shown.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SZxLsslDI-I/AAAAAAAAAEo/aumVXgiMV1k/s1600-h/cl.bmp"&gt;&lt;img src="http://4.bp.blogspot.com/_s6gSPX95als/SZxLsslDI-I/AAAAAAAAAEo/aumVXgiMV1k/s320/cl.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304197692388484066" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 213px; height: 290px; " /&gt;&lt;/a&gt;&lt;p class="MsoNormal"&gt;&lt;span&gt;In the properties tag below choose the thickness as 3 as shown.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); "&gt;&lt;img src="http://3.bp.blogspot.com/_s6gSPX95als/SZxMUSi_jLI/AAAAAAAAAE4/5GtM1SFT0mo/s320/th.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304198372595305650" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 39px; " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SZxLsslDI-I/AAAAAAAAAEo/aumVXgiMV1k/s1600-h/cl.bmp"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;While pressing the Shift button draw a circle with width and height of 200 as shown&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_s6gSPX95als/SZxMrBIrejI/AAAAAAAAAFA/SUe_qPKikVM/s1600-h/c.bmp"&gt;&lt;img src="http://2.bp.blogspot.com/_s6gSPX95als/SZxMrBIrejI/AAAAAAAAAFA/SUe_qPKikVM/s320/c.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304198763058526770" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 157px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;Go to “Window-&gt;Allign” and click on “Allign Horizontal Centre” and “Allign Vertical Centre”. &lt;span style="mso-spacerun:yes"&gt; &lt;/span&gt;Make sure “To Stage ” is selected.&lt;/div&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); "&gt;&lt;img src="http://4.bp.blogspot.com/_s6gSPX95als/SZxM3cM4HWI/AAAAAAAAAFI/5MHUgviKclE/s320/al.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304198976482319714" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 218px; height: 156px; " /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Click on the button encircled below to make 4 new layers and name them as actions, hour, min and sec. Your timeline shoul look like this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SZxOU8LZKdI/AAAAAAAAAGA/iP2PTz4Cw38/s1600-h/tl.bmp"&gt;&lt;img src="http://3.bp.blogspot.com/_s6gSPX95als/SZxOU8LZKdI/AAAAAAAAAGA/iP2PTz4Cw38/s320/tl.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304200582793865682" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 71px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: center;"&gt;Click on the first frame of the sec layer. Select the Line Tool and draw a vertical line of length 90. Select the line and hit F8 to save it as a symbol.&lt;span style="mso-spacerun:yes"&gt;  &lt;/span&gt;Set it as follows. Make sure you click the bottom centre registration.&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SZxNmP1ViHI/AAAAAAAAAFQ/sdLB3YbKJk4/s1600-h/ob.bmp"&gt;&lt;img src="http://4.bp.blogspot.com/_s6gSPX95als/SZxNmP1ViHI/AAAAAAAAAFQ/sdLB3YbKJk4/s320/ob.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304199780616210546" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 297px; height: 320px; " /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Click OK and in the Properties tag set the name as sec_mc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SZxOpgz-KgI/AAAAAAAAAGI/QHQIcRHLoP4/s1600-h/pp.bmp"&gt;&lt;img src="http://3.bp.blogspot.com/_s6gSPX95als/SZxOpgz-KgI/AAAAAAAAAGI/QHQIcRHLoP4/s320/pp.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304200936225122818" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 58px; " /&gt;&lt;/a&gt;&lt;p class="MsoNormal"&gt;Go to “Window -&gt; Library” and right click on sec_mc and click “Duplicate”. Name it as min_mc. Right click on min_mc and hit “Edit”. Select the line ad set its height in the properties tag as 75. Change the color.&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Redo the above and name it as hour_mc with height 50 and a different color.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Click on the first frame of the min layer and drag min_mc on stage. Set the instance name as min_mc. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Click on the first frame of the hour layer and drag hour _mc on stage. &lt;span style="mso-spacerun:yes"&gt; &lt;/span&gt;Set the instance name as hour _mc. &lt;span style="mso-spacerun:yes"&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Press Shift and select all three lines and in the Allign window click “Allign Bottom Edge ” and “Allign Horizontal Centre”. Drag all three to the centre of the circle drawn.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Right Click on the first frame of the actions layer and click “Actions”.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;In the window that opens Copy and Paste the followin action script:-&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var my_time:Date=new Date;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var hours, min, sec;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 153, 153);"&gt;//get the present hour minute and second&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;hours=my_time.getHours();&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;sec=my_time.getSeconds();&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;min=my_time.getMinutes();&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;hours = hours + (min/60);&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;min=min*6 +(sec/60);&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;hours=hours*30;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;sec=sec*6;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;hour_mc._rotation = hours;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;sec_mc._rotation = sec;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;min_mc._rotation = min;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes"&gt;Right Click on the second frame of each Layer and click “Insert Frame”. Your final timeline should look like this :-&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SZxNmfBwRLI/AAAAAAAAAFo/dgA1qc4o4mQ/s1600-h/ftl.bmp"&gt;&lt;img src="http://4.bp.blogspot.com/_s6gSPX95als/SZxNmfBwRLI/AAAAAAAAAFo/dgA1qc4o4mQ/s320/ftl.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304199784694826162" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 74px; " /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Done! Hit Ctrl+Enter to test what you have done. &lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_s6gSPX95als/SZxNmb3LkfI/AAAAAAAAAFg/Om0Da8A-35o/s1600-h/ex.bmp" style="text-decoration: none;"&gt;&lt;br /&gt;&lt;img src="http://3.bp.blogspot.com/_s6gSPX95als/SZxNmb3LkfI/AAAAAAAAAFg/Om0Da8A-35o/s320/ex.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304199783845171698" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 258px; " /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Use your Imagination to change the background to make the clock look stylish. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_s6gSPX95als/SZxNmTQkT9I/AAAAAAAAAFw/DdYiQAmrOlw/s1600-h/ex1.bmp"&gt;&lt;img src="http://4.bp.blogspot.com/_s6gSPX95als/SZxNmTQkT9I/AAAAAAAAAFw/DdYiQAmrOlw/s320/ex1.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5304199781535731666" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 258px; " /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-3483113499491446912?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/3483113499491446912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/02/color-mixer-and-set-it-shown_18.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3483113499491446912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/3483113499491446912'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/02/color-mixer-and-set-it-shown_18.html' title='Flash Analog Clock Tutorials'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_s6gSPX95als/SZxLsslDI-I/AAAAAAAAAEo/aumVXgiMV1k/s72-c/cl.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-9052736350680675742</id><published>2009-01-02T10:50:00.000+05:30</published><updated>2009-02-18T20:54:54.848+05:30</updated><title type='text'>Animated and Custom Mouse Pointer Video Tutorial</title><content type='html'>If you want to create a Custom Pointer then follow the steps given below and watch the video&lt;br /&gt;&lt;br /&gt;1&gt; Create the shape you want the pointer to be.&lt;br /&gt;&lt;br /&gt;2&gt; Select the shape and press F8 or "Right Click-&gt;Convert To Symbol" and name it as pointer_mc select Movie Clip Option and click ok&lt;br /&gt;&lt;br /&gt;3&gt;Right Click on the object and select actions.  On the window that opens  copy and paste the following action script :-&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;onClipEvent(load)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    Mouse.hide();&lt;span style="color: rgb(153, 153, 153);"&gt; //Hides the Mouse Pointer    &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;onClipEvent(enterFrame)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    this._x = _root._xmouse;&lt;span style="color: rgb(153, 153, 153);"&gt; //assigns the x coordinate of this object as that of the mouse&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    this._y = _root._ymouse; &lt;span style="color: rgb(153, 153, 153);"&gt;//assigns the y coordinate of this object as that of the mouse&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;onClipEvent(mouseUp)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;    Mouse.hide(); &lt;span style="color: rgb(153, 153, 153);"&gt;//to hide the mouse pointer after a right click&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4 &gt; Press Ctrl+Enter to Test the Movie.&lt;br /&gt;&lt;br /&gt;5 &gt; Watch the Video for Clarifications&lt;br /&gt;&lt;br /&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-ee2a17a16c4b2e0d" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v23.nonxt1.googlevideo.com/videoplayback?id%3Dee2a17a16c4b2e0d%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330223288%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D84A1F4673BE94EFC7942B8C3D63A5574190DB632.5F0A473BB67BBBD2395E07D198B75569F43016BD%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Dee2a17a16c4b2e0d%26offsetms%3D5000%26itag%3Dw160%26sigh%3DeMH2Jc5ncSB-cwcJO3UMr7wRJMI&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v23.nonxt1.googlevideo.com/videoplayback?id%3Dee2a17a16c4b2e0d%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330223288%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D84A1F4673BE94EFC7942B8C3D63A5574190DB632.5F0A473BB67BBBD2395E07D198B75569F43016BD%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Dee2a17a16c4b2e0d%26offsetms%3D5000%26itag%3Dw160%26sigh%3DeMH2Jc5ncSB-cwcJO3UMr7wRJMI&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div&gt;Contact Me At :- subhrojit86@gmail.com&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-9052736350680675742?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=ee2a17a16c4b2e0d&amp;type=video%2Fmp4' length='0'/><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/9052736350680675742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/01/animated-and-custom-mouse-pointer-video.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/9052736350680675742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/9052736350680675742'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/01/animated-and-custom-mouse-pointer-video.html' title='Animated and Custom Mouse Pointer Video Tutorial'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-2348313154930488581</id><published>2009-01-01T20:46:00.000+05:30</published><updated>2009-02-18T20:55:22.901+05:30</updated><title type='text'>Introduction to the Timeline and Vector Graphics Tutorials in Flash</title><content type='html'>This is a tutorial for vector graphics and an introduction to the Timeline. It is a tutorial for absolute beginners.Enjoy&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Difficulty :- 1/5&lt;/div&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-4cbb9c32308cbb5b" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v4.nonxt8.googlevideo.com/videoplayback?id%3D4cbb9c32308cbb5b%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330223288%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D82524C26D78D4E61CF1ADB162962ACD2BB659DB1.7623BDEFB20882F7BF4EE807EE55D4060B18416C%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D4cbb9c32308cbb5b%26offsetms%3D5000%26itag%3Dw160%26sigh%3DUlwtFbkuhuPycPq-Uq5oaLvKzF8&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v4.nonxt8.googlevideo.com/videoplayback?id%3D4cbb9c32308cbb5b%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1330223288%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D82524C26D78D4E61CF1ADB162962ACD2BB659DB1.7623BDEFB20882F7BF4EE807EE55D4060B18416C%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D4cbb9c32308cbb5b%26offsetms%3D5000%26itag%3Dw160%26sigh%3DUlwtFbkuhuPycPq-Uq5oaLvKzF8&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div&gt;Contact Me At :- subhrojit86@gmail.com&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-2348313154930488581?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=4cbb9c32308cbb5b&amp;type=video%2Fmp4' length='0'/><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/2348313154930488581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2009/01/introduction-to-timeline-and-vector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2348313154930488581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/2348313154930488581'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2009/01/introduction-to-timeline-and-vector.html' title='Introduction to the Timeline and Vector Graphics Tutorials in Flash'/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8107625831108404275.post-859554059125794974</id><published>2008-12-29T20:01:00.000+05:30</published><updated>2009-02-18T20:09:54.946+05:30</updated><title type='text'></title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Living in Asansol and studying in NIT, Durgapur meant that I could literally avoid staying at the hostel. Inspite of the very bad condition and worse food of Hall 2, one of the few things that made me stay back, even on weekends, was our LAN. I might also add that I didn't even know how to switch on a computer before I came to this college. I could just program in LOGO and BASIC if somebody switched the machine on and started MS DOS so anyway I was hungry for anything there was to know about computers and Windows XP. Then one day I came across a folder shared on the LAN called "Flash Tutorials". I had already been a student of this college and of the CSE department no less, for more than three semesters, so it was pretty hard to get myself to study whats in the normal curriculum let alone a tutorial about something I hadn't heard about in someone else's computer. The only thing that drew me to that folder was most of the files in the folder, with the .swf extension, would not open because I did not have the required software. So I got curious ,looked for the software in the internet and found out that i needed a Flash Player. So I installed it and opened the files. They were tutorials on how to use Macromedia Flash Professional 8.0. They left me awstruck and I've been in love with it since. I've learned quite a bit over this time and want to share my knowledge with those who are new to the magic that is Flash!!  &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8107625831108404275-859554059125794974?l=learnflashwithme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learnflashwithme.blogspot.com/feeds/859554059125794974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learnflashwithme.blogspot.com/2008/12/living-in-asansol-and-studying-in-nit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/859554059125794974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8107625831108404275/posts/default/859554059125794974'/><link rel='alternate' type='text/html' href='http://learnflashwithme.blogspot.com/2008/12/living-in-asansol-and-studying-in-nit.html' title=''/><author><name>Subhrojit Nag</name><uri>http://www.blogger.com/profile/03102755207816752414</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_s6gSPX95als/SplYLP9XykI/AAAAAAAAASA/vskGOQD_WVc/S220/me.jpg'/></author><thr:total>0</thr:total></entry></feed>
