tag:blogger.com,1999:blog-52362913088384649952024-02-19T15:49:38.862+11:00Flash & ActionScriptThis Blog is all about Flash & ActionScript.Atul Naranghttp://www.blogger.com/profile/18070505978115042549noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-5236291308838464995.post-73652227215894254802010-07-13T10:42:00.003+10:002010-07-13T14:52:58.477+10:00Reading variables from text file in AS3This post will explain how to read data from variables stored in a text file.<br /><br />The format of the text file will be as follows -<br /><br /><span style="font-style: italic;"><span>var_1=first variable&var_2=second variable </span></span><br /><br />You can have any number of variables defined in this text file.<br /><br />The AS3 code will be as follows -<br /><br /><span style="font-style: italic;"><span class="value">var</span><span> loader:</span><span class="value">URLLoader</span><span> = </span><span class="value">new</span><span> </span><span class="value">URLLoader</span><span>(); </span></span><br /><span style="font-style: italic;"> </span><br /><span style="font-style: italic;"><span class="green">//telling the loader that we are dealing with variables here.</span><span> </span></span><br /><span style="font-style: italic;">loader.<span class="value">dataFormat</span><span> = </span><span class="value">URLLoaderDataFormat</span><span>.VARIABLES; </span></span><br /><span style="font-style: italic;"> </span><br /><span style="font-style: italic;"><span class="green"></span></span><br /><span style="font-style: italic;">loader.<span class="value">addEventListener</span><span>(</span><span class="value">Event</span><span>.</span><span class="value">COMPLETE</span><span>, loading); </span></span><br /><span style="font-style: italic;"> </span><br /><span style="font-style: italic;"><span class="green">//Name of the text file to load.</span><span></span></span><br /><span style="font-style: italic;">loader.load(<span class="value">new</span><span> URLRequest(</span><span class="green">"content.txt"</span><span>)); </span></span><br /><span style="font-style: italic;"> </span><br /><span style="font-style: italic;"><span class="green"></span></span><span style="font-style: italic;"><span class="green">//news_1 & news_2 are the dynamic text fields on the stage to display the values being read.</span></span><br /><span style="font-style: italic;"><span class="value">function</span><span> loading (</span><span class="value">event</span><span>:</span><span class="value">Event</span><span>):</span><span class="value">void</span><span> { </span></span><br /><span style="font-style: italic;"> news_1.text = loader.<span class="value">data</span><span>.var_1 </span></span><br /><span style="font-style: italic;"> news_2.text = loader.<span class="value">data</span><span>.var_2 </span></span><br /><span><span style="font-style: italic;">}<br /><br /></span>So with the above mentioned code we can read the values of var_1 and var_2 stored in the text file and populate the .text property of the dynamic text boxes sitting on stage to display those values.<span style="font-style: italic;"><br /></span></span>Atul Naranghttp://www.blogger.com/profile/18070505978115042549noreply@blogger.com1tag:blogger.com,1999:blog-5236291308838464995.post-15934821333071303172010-06-23T21:43:00.009+10:002010-06-23T22:27:59.831+10:00How to switch to fullscreen mode in AS3Following is the code for the Flash -<br /><br />import flash.display.StageDisplayState;<br />function goFullScreen():void {<br />if (stage.displayState == StageDisplayState.NORMAL) {<br />stage.displayState=StageDisplayState.FULL_SCREEN;<br />} else {<br />stage.displayState=StageDisplayState.NORMAL;<br />}<br />}<br />stage.addEventListener(MouseEvent.CLICK, _handleClick);<br />function _handleClick(event:MouseEvent):void {<br />goFullScreen();<br />}<br /><br />Function _handleClick will be called as soon user clicks on the stage which will execute the function goFullScreen which will set the displayState to full screen.<br /><br />This will only work once you have embedded the flash in HTML and view it in the browser. Another important thing to keep in mind is to set allowFullScreen paramter in the embedding code to true.<br /><br />In the flash embedding code you will need to have the following -<br /><br /><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="test" align="middle"><br /><br /><param name="allowScriptAccess" value="sameDomain" /><br /><br /><strong><param name="allowFullScreen" value="true" /></strong><br /><param name="movie" value="test.swf" /><br /><param name="quality" value="high" /><br /><param name="bgcolor" value="#ffffff" /><br /><br /><embed src="test.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="test" align="middle" allowScriptAccess="sameDomain" <strong>allowFullScreen="true"</strong> type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br /><br /></object>Atul Naranghttp://www.blogger.com/profile/18070505978115042549noreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-90544345193712998972010-05-28T13:23:00.003+10:002010-05-28T13:32:14.608+10:00XML Parser AS2 and AS3It's been ages, since I last posted on my blog. I have been really busy at work managing expectations.<br /><br />People interested in XML parsing for dynamic websites or applications, there is an easy way of doing it rather than getting into every node and fetching values specifically in AS2. You can download XML Parser from Greensock here -<br /><br />http://www.greensock.com/xmlparseras2/<br /><br />It's pretty easy to work with XML using this class if you are coding in AS2 and you can find an example on the above mentioned page itself.<br /><br />Also from the same page you can find a link to download the XML Parser for AS3 as well.Atul Naranghttp://www.blogger.com/profile/18070505978115042549noreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-85822616759674913792009-12-01T17:34:00.004+11:002009-12-01T17:43:42.743+11:00Passing values to Flash using swfobject and capturing in Flash using AS3Just like flashvars you can pass values to Flash even if you are using swfobject to display your flash. Below is the code to do that -<br /><br />var so = new SWFObject("flash/465x535.swf", f_size, "385", "535", "9", "");<br />so.addVariable("file_path", "filename.jpg");<br /><br />file_path is the variable which will be passed to Flash. Now to capture the value in Flash using AS3 the code will be as follows -<br /><br />var filepath = root.loaderInfo.parameters.file_path;Atul Naranghttp://www.blogger.com/profile/18070505978115042549noreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-41302965934941503102009-10-07T11:32:00.005+11:002009-10-07T13:10:03.075+11:00Passing values between Flash and ASP.NetRecently I had to integrate Flash and ASP.Net for Harley's test ride website because the website has been built in Flash and the data needs to be passed to asp.net which subsequently stores it in the MS-SQL database.<br /><br />I had done it in the past and I was following the same approach but somehow the values which were returned from asp.net to flash were the complete code of the webpage whereas I was only passing "passed" or "invalid" to take some action in Flash depending upon the output from Asp.Net<br /><br />After doing hours of search on the internet and R&D I finally found the problem and so to save time to my fellow developers I am posting the complete code below -<br /><br /><span style="font-weight: bold;">Flash Source Code:</span><br /><span style="font-style: italic;">var dataSender:LoadVars = new LoadVars();</span><br /><span style="font-style: italic;">var dataReceiver:LoadVars = new LoadVars();</span><br /><span style="font-style: italic;">dataSender.email="atul.narang@designworxz.com";</span><br /><span style="font-style: italic;">dataReceiver.onLoad = function() {</span><br /><span style="font-style: italic;"> if (dataReceiver.response == "invalid") {</span><br /><span style="font-style: italic;"> gotoAndStop(1);</span><br /><span style="font-style: italic;"> } else if (dataReceiver.response == "passed") {</span><br /><span style="font-style: italic;"> gotoAndStop(4);</span><br /><span style="font-style: italic;"> }</span><br /><span style="font-style: italic;"> }</span><br /><span style="font-style: italic;">dataSender.sendAndLoad("bookatestride.aspx", dataReceiver, "GET");</span><br /><br /><span style="font-weight: bold;">C# Source Code:</span><br /><span style="font-style: italic;">public partial class bookatestride : System.Web.UI.Page </span><br /><span style="font-style: italic;">{</span><br /><span style="font-style: italic;"> protected void Page_Load(object sender, EventArgs e)</span><br /><span style="font-style: italic;"> {</span><br /><span style="font-style: italic;"> if (....)</span><br /><span style="font-style: italic;"> {</span><br /><span style="font-style: italic;"> Response.Write("&response=passed&");</span><br /><span style="font-style: italic;"> }</span><br /><span style="font-style: italic;"> else</span><br /><span style="font-style: italic;"> {</span><br /><span style="font-style: italic;"> Response.Write("&response=invalid&");</span><br /><span style="font-style: italic;"> }</span><br /><span style="font-style: italic;"> }</span><br /><span style="font-style: italic;">}</span><br /><br />dataSender is calling the bookatestride.aspx page and passing one value in the variable called "email". In return aspx page is passing variable-value pair and that gets stored into the dataReceiver object.<br /><br />I wasn't including "&" in the response.write and that was the reason I had wasted few hours trying to figure this out. So guys don't forget to include "&" in your Response.writeAtul Naranghttp://www.blogger.com/profile/18070505978115042549noreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-80722699968556640952009-06-25T09:19:00.002+10:002009-06-25T09:25:14.974+10:00Embed fonts in FlashTo embed the fonts for a dynamic text field in Flash select the text field and open the properties panel. In the properties panel you will be able to see a button called "Embed", click on that and it will ask you what all you want to embed such as Uppercase letters, Lowercase letters or Numerics.<br /><br />Select the appropriate and press Ok and you are done.Atul Naranghttp://www.blogger.com/profile/18070505978115042549noreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-40565736673217617822009-05-25T14:22:00.007+10:002009-05-25T14:54:36.773+10:00JSON to Flash: YouTube Case StudyI had to implement a custom YouTube gadget in Flash. The term gadget does not refer to a specific gadget technology, such as Google Gadgets. YouTube Gadget refers only to small web applications, implemented in HTML or Flash, that are displayed within an iFrame on a YouTube brand channel.<br /><br />And for that purpose I had to fetch the list of videos published by a particular YouTube user which can only be fetched in the form of JSON, RSS or Atom Feed. I decided to go with JSON, initially it was difficult for me to fetch the appropriate values I needed because the JSON returned by YouTube is quite complex in structured but finally I was able to sort it out.<br /><br />JSON stands for JavaScript Object Notation and is mainly used to transmit such structured data over a network connection.<br /><br />Example:<br /><code>{<br />"firstName": "Atul",<br />"lastName": "Narang"<br />}<br /><br /></code>In my case the JSON has to be parsed from the following URL -<br />http://gdata.youtube.com/feeds/api/videos?max-results=5&alt=json&orderby=published&author=designworxz<br /><br />If you change the last parameter in the URL which is "author=designworxz" to "author=your youtube username" it will fetch list of videos published by you in the form of JSON.<br /><br />The great community over at <a href="http://json.org/">http://json.org</a> have created a JSON parsing library for AS1, AS2 & AS3. But we will focus on Flash CS3 & AS2.0. You can find that parse class here: <a href="http://json.org/JSON.as">http://json.org/JSON.as</a><br /><br />Below is the code to parse the JSON returned by YouTube -<br /><br /><code><br />import JSON;<br /><br />var jsondata:LoadVars = new LoadVars();<br /><br />jsondata.onLoad = function(success) {<br /><br /> if (success) {<br /> trace("load successful");<br />var o:Object = json.parse(</code><code>unescape(this.toString())</code><code>);<br />var s:String = json.stringify(o);<br />trace(s);<br /> } else {<br /> trace("unable to load JSON data");<br /> }<br />};<br /><br />jsondata.load("http://gdata.youtube.com/feeds/api/videos?max-results=5&alt=json&orderby=published&author=designworxz");<br /></code><br />The variable "s" will display the complete JSON returned by YouTube in the Output window & then the only thing you have to do is to fetch the required String, Variables & Values from the returned JSON.<br /><br />Good Luck!!Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-5236291308838464995.post-52584343637659388892009-03-16T12:50:00.003+11:002009-03-16T12:56:56.465+11:00Flash CS3 UI ScrollbarGuys, if you attach the UI Scrollbar component with Dynamic textbox in Flash where the text will be populated from XML or a Text file, the scrollbar won't work and resize automatically.<br /><br />When I was working on one of my flash component where the data was being populated from XML, I assumed that the scrollbar will automatically adjust according to the amount of the data but nothing really happened.<br /><br />So to make the scrollbar work after you have populated your dynamic textbox with the content you can type the following action to make the UIScrollbar work -<br /><br /><span style="font-style: italic;">mc_scroll.maxScrollPosition = details.textHeight;</span><br /><br />"mc_scroll" is the instance name of my scrollbar attached with the dynamic textbox & "details" is the name of my dynamic text box.Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-5236291308838464995.post-58836646799782297792009-03-13T17:43:00.000+11:002009-03-13T17:51:35.016+11:00Playing multiple videos Dynamicallyimport flash.media.Video;<br />import flash.net.NetConnection;<br />import flash.net.NetStream;<br /><br />Create a connection object<br /><br />var connection_nc:NetConnection = new NetConnection();<br />connection_nc.connect(null);<br /><br />Create a NetStream object and pass the NetConnection object<br /><br />var stream_ns:NetStream = new NetStream(connection_nc);<br />stream_ns.client = new Object();<br /><br />One connection object can be used for more than one video stream.<br /><br />myVideo.attachNetStream(stream_ns);<br />stream_ns.play("video.flv");<br /><br />myVideo is the name of my video object placed on the stage & video.flv is the video file which needs to be played. Now if you want to play another video you have to create a new NetStream object for each video otherwise it will not work. I spent 4 hours just to figure this out & kept trying different techniques to make my 4 different videos work with the same NetStream object. But unfortunately it is not possible.<br /><br />So guys the trick is to create different NetStream object for each video & have fun.<br /><br />Happy Streaming!!!Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5236291308838464995.post-28763900622282777212009-03-11T11:47:00.000+11:002009-03-11T12:39:56.142+11:00Flash XML parsing including HTML tags in the XMLIf you want to parse the HTML tags within your XML, the XML document should look like below -<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1f0heU-zTQCeBdCZ19TMukjYtNDck8vas9hb-w0Fv6yyfxxCRrFXhYkgWTSNCeD0fMzXJdXaKyqeENvLrGqUW7URpgrtaO2NKuocjYyRoMg1mOAVQCCzeToEC0UZbvn9en4dd6jOelQ/s1600-h/Picture+2.png"><img style="cursor: pointer; width: 243px; height: 78px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1f0heU-zTQCeBdCZ19TMukjYtNDck8vas9hb-w0Fv6yyfxxCRrFXhYkgWTSNCeD0fMzXJdXaKyqeENvLrGqUW7URpgrtaO2NKuocjYyRoMg1mOAVQCCzeToEC0UZbvn9en4dd6jOelQ/s400/Picture+2.png" alt="" id="BLOGGER_PHOTO_ID_5311738236404316658" border="0" /></a><br /><br />And in the Flash scripting if you have a Dynamic Textbox named dynTxt the code will be as follows -<br /><br />dynTxt.htmlText = <span style="font-style: italic;">Variable holding your text data</span><br /><br />Following are the tags supported by Flash while parsing XML-<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7d3yanoMb2rsBRsYXjY_z7neYdUbU9_uxWtkN1U-mLoca7-9JoM7AV-hnXGRgefoG8aEGZ23nCqRQagFo_Z9OHj1RVLR-bgwQQp_jjs_Udj3sl_qg9OUjDeLw5qSO1NwSBGmQRtv4qw/s1600-h/Picture+3.png"><img style="cursor: pointer; width: 400px; height: 182px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7d3yanoMb2rsBRsYXjY_z7neYdUbU9_uxWtkN1U-mLoca7-9JoM7AV-hnXGRgefoG8aEGZ23nCqRQagFo_Z9OHj1RVLR-bgwQQp_jjs_Udj3sl_qg9OUjDeLw5qSO1NwSBGmQRtv4qw/s400/Picture+3.png" alt="" id="BLOGGER_PHOTO_ID_5311738511055356306" border="0" /></a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-8101871761782456072009-03-11T11:35:00.000+11:002009-03-11T11:46:22.531+11:00Mask on Dynamic TextboxI encountered a strange problem in Flash when I tried masking a dynamic text box and it didn't work. After doing lots of research on the internet I found out that if you mask a dynamic text box the text won't appear. <br /><br />So to save time for the people trying to mask the dynamic text box here is the tip, click your text box in the properties panel click the Embed button and embed the fonts and your text will start appearing again.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5236291308838464995.post-27128279444355135542009-02-26T15:46:00.000+11:002009-02-26T15:47:27.862+11:00Online Rugby GameI have recently finished an online Rugby Game which can be accessed at - www.303.com.au/projects/rugby/rugby.html<br /><br />Hope you like it!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-11091150308241304562009-02-26T15:38:00.000+11:002009-02-26T15:43:58.438+11:00ReferenceError: Error #1065I could not post any entries in the last few months because of my busy schedule & finally I got a chance to post this problem with AS3.0 while parsing XML.<br /><br />While parsing XML I came through this error -<br /><br />ReferenceError: Error #1065<br /><br />which is kind of vague error, I could not find anything anything related to my code even after searching for hours. Finally I decided to jump into my XML & keep only few entries to test & it worked. <br /><br />After sweating for hours I found the error in the XML because one of the node was missing. So guys if you are getting this error while parsing XML, jump into the XML and check your structure.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-32026544049332572502008-09-22T11:24:00.000+10:002008-09-22T11:31:00.906+10:00Tweening with AS3Fellow Flash Devs,<br /><br />I have finally started playing with AS3 & tried doing some experimentation with Tween class. <br /><br />It's as simple as before except the classes which needs to be imported are different. So for AS3 we will import fl.transitions.Tween & fl.transitions.easing.*<br /><br />Please use the code below to simply animate a box kept on the stage using Tween class-<br /><br />import fl.transitions.Tween;<br />import fl.transitions.easing.*;<br /><br />b1.buttonMode = true;<br />b1.addEventListener(MouseEvent.CLICK, btnclick);<br /><br />function btnclick(event:MouseEvent)<br />{<br /> new Tween(b1,"x",Regular.easeOut, b1.x, b1.x+50,1, true);<br />}Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-79263149321854656632008-07-24T19:57:00.000+10:002008-07-24T20:05:05.313+10:00Problem with Combobox componentWhile working on a website for one of my client, I came across a strange problem with Combobox component. <br /><br />If you try to put a Combobox in a flash & then try to load that .swf file in another flash using loadClip function of MovieClipLoader it doesn't work. You can't even click it to see the items.<br /><br />After googling for sometime I found that its a bug in Flash and the work around is if you simply drag a Combobox component in your parent Flash & then just delete it from the stage leaving it in the library, it works perfectly fine. <br /><br />And you can click and select any item from the Combobox embedded in the child Flash, loaded in the parent movie.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5236291308838464995.post-47272424371644842752008-06-04T11:31:00.000+10:002008-06-04T11:48:00.906+10:00Tweening with MC TweenAfter the Tween & TransitionManager Class, to make life more easier I have found MC Tween extension which can be used to tween objects such as movieclip/sound/textfield.<br /><br />You just need to #include "mc_tween2.as" and use one simple command to create a new tweening. It doesn't use the MovieClip's own onEnterFrame event & It is based on time, not on frames.<br /><br />Let's suppose you want to move something using an animation, to provide a smoother experience for the user. Using MC Tween, you could do:<br />myMovieclip.tween("_x", 100);<br /><br />To download the extension or read the full documentation with examples please go to: http://hosted.zeh.com.br/mctween/Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-42690478739376400562008-05-12T10:09:00.000+10:002008-05-12T10:24:25.938+10:00Auto SaveHi Guys,<br /><br />You can enable autosaving for your flash documents in Flash by downloading and installing the extension -<br /><br />Extension:<a href="http://www.designworxz.com/blogger/auto.save.mxp">Auto save extension</a><br /><br />You can set the autosave intervals as per your needs.<br /><br />This extensions is licensed under a <a onclick="javascript:pageTracker._trackPageview('/outgoing/creativecommons.org/licenses/by-nd/1.0/');" href="http://creativecommons.org/licenses/by-nd/1.0/">Creative Commons License</a>. If you choose to download it then you are agreeing to the terms in this <a onclick="javascript:pageTracker._trackPageview('/outgoing/creativecommons.org/licenses/by-nd/1.0/legalcode');" href="http://creativecommons.org/licenses/by-nd/1.0/legalcode">license agreement</a>.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-60133255042097706502007-07-19T09:44:00.000+10:002007-07-19T10:11:35.764+10:00Beauty of Tweening with Tween & TransitionManager classYes!!! Its true that you can tween any object on the stage without actually applying tweening in the timeline & its amazing.<br /><br />I am pasting a small code snippet below for a quick reference, which generates a bounce effect for a movie clip placed on the stage.<br /><br /><span style="font-weight:bold;">import mx.transitions.Tween; <br />import mx.transitions.easing.*; <br /><br />new Tween(mcBall, "_y", Bounce.easeOut, 0, Stage.height-50, 3, true); </span><br /><br />Parameters Explained:<br />1. "mcBall" is the movie clip placed on the stage<br />2. This parameter tells the constructor that what property will change in case of tweening. "_y" means the y position of the movie clip has to be changed.<br />3. The effect.<br />4. Starting y position.<br />5. End y position.<br />6. Duration of the tween.<br />7. Boolean Value related to the duration parameter, which indicates to use seconds if true, or frames if false.<br /><br />The Tween and TransitionManager classes are available only in ActionScript 2.0, but these classes are available in both Flash Basic 8 and Flash Professional 8.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-89706394063153411252007-07-18T14:46:00.000+10:002007-07-18T15:16:40.657+10:00Actionscript/Javascript CommunicationNow its much easier to communicate with Flash from Javascript and vice versa using ExternalInterface class.<br /><br />You can create any function in Flash & then use the ExternalInterface class to register that function to call from the browser.<br /><br />I am giving a step by step explanation to achieve the desired functionality. <br /><br />First and foremost import the package using the statement given below -<br /><br /><span style="font-weight:bold;">import flash.external.*;</span><br /><br />& then call the following function to register the function<br /><br /><span style="font-weight:bold;">ExternalInterface.addCallback("callASFunction", null, asFunction);</span><br /><br /><span style="font-weight:bold;">Explanation:</span> The first parameter "callASFunction" is the name which will be used to call the function from the browser and the third parameter is the actual name of the function created in Flash. You can always keep the second parameter as null.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-50534272229366540272007-06-18T14:49:00.000+10:002007-06-18T15:24:42.716+10:00Mobile Apps with Flash LiteHi Peeps,<br /><br />I just tried playing around with Flash Lite & found it really cool to generate mobile apps & you can test your application in the emulator while developing it. <br /><br />I created a very small application & found it really interesting and easy. I used Flat Lite 1.1 with Flash 8.0 to generate this application.<br /><br />I had an image & a button placed in the first screen & clicking on that button made the image run out of the screen with motion tween. <br /><br />It was fun & easy.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-73328424941607407782007-06-07T11:22:00.000+10:002007-07-18T15:17:55.537+10:00Customizing Flash Context MenuFlash context menu is the menu you see when you right click on any of the running Flash animations or applications.<br /><br />I have customized it many times before but one of my friend asked me few days back that if he can remove the options from the Flash shortcut(context) menu so I thought of posting it on my blog for all of those trying to customize it.<br /><br />I am pasting the code along with the explanation below -<br /><br /><span style="font-weight:bold;">var cMenu = new ContextMenu();<br />cMenu.hideBuiltInItems();<br /><br />function dummy() { <br />trace("option clicked");<br />}<br />var cMenuItem1 = new ContextMenuItem("Option 1", dummy);<br />var cMenuItem2 = new ContextMenuItem("Option 2", dummy);<br />var cMenuItem3 = new ContextMenuItem("Option 3", dummy);<br />cMenu.customItems.push(cMenuItem1,cMenuItem2,cMenuItem3);<br />_root.menu = cMenu;</span><br /><br />The ContextMenu class provides runtime control over the items in the Flash Player context menu, which appears when a user right-clicks on Flash Player.<br /><br />First of all I have created an object of the class ContextMenu called "cMenu" & then called the built in function hideBuiltInItems() using the object which will hide the default options appearing on the right click.<br /><br />The function dummy has been created to display a message in the output panel whenever user will click on the customized options added in the menu.<br /><br />ContextMenuItem class is used to create objects for creating customized items, so for each option you want to put in the menu, you have to create an object. While creating object it takes two parameters, the caption & the function which will be executed on the click.<br /><br />After doing this you have to push the items in the menu and to do that you use in built array associated with ContextMenu called ContextMenuItems.<br /><br /><span style="font-weight:bold;">cMenu.customItems.push(cMenuItem1,cMenuItem2,cMenuItem3);<br /></span><br />So using the above code you push the items created into the menu & then your menu is ready to go after you change the current menu by putting in your menu name in the "menu" property using the following statement -<br /><span style="font-weight:bold;"><br />_root.menu = cMenu;</span><br /><br />Enjoy Customizing Context Menu...Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5236291308838464995.post-15438309960986349472007-05-24T11:23:00.001+10:002007-07-18T15:18:38.611+10:00XML PreloaderHey Guys,<br /><br />Now you can show a preloader animation even while loading any data from a XML file. The code for the preloader is like any other preloader in Flash except there is a change while extracting the loaded and total bytes -<br /><br /><span style="font-weight:bold;">loadedBytes=myXML.getBytesLoaded();<br />totalBytes=myXML.getBytesTotal();</span><br /><br />myXML here refers to your XML object created to load the XML file.<br /><br />Please feel free contact me at <a href="mailto:atul.narang@yahoo.com">atul.narang@designworxz.com</a> in case of any query.<br /><br />Cheers :)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-65486529935640542752007-04-27T16:48:00.000+10:002007-04-27T17:02:26.741+10:00Loading Image DynamicallyI don't recommend to use LoadMovie for loading images dynamically because you can not actually trace the progress & perform the next action depending upon the progress.<br /><br />I will suggest using MovieClipLoader class and its function loadClip using which you can actually trace the progress & if required can play preloader animation & then hide it when the loading of image is completed.<br /><br />Please feel free to post your query if you have any.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5236291308838464995.post-24681604870343526322007-04-26T12:04:00.000+10:002007-04-27T17:03:54.338+10:00Parsing XML in FlashXML2Object is an extension for Macromedia Flash & just to let those people know who are creating dynamic website or applications by integrating & reading data from XML that it makes your life very easy by creating an object of complete XML.<br /><br />After creating an object of XML2Object you can extract data by using the following format -<br />ObjectName.nodename.data<br /><br />It is very easy & faster to use rather than parsing through each node of XML file & then extracting the data.Unknownnoreply@blogger.com0