Webcam Motion Detection using AS3.
Some time back Guy Watson wrote an article in the developer center called Webcam Motion Detection: Using the BitmapData API in Flash 8. He later made a better version of it and included that source in the zip file. I went through that code and completely rewrote it in ActionScript 3. Here is the demo. This one of course requires a webcam and flash 9 player to play around. Once I clean up the...
Read MoreDesigning a Search Field .
Utilizing the available application space effectively is one of the important things we need to consider when designing an user interface. Olden search interfaces had two parts text input field and a search button. Then the “search”/”find”/”go” text is replaced with a lens icon. Now a days this lens icon is embedded inside the input text itself. If you want...
Read MoreEnhancing the Blog Reader Example.
In the Live docs you might have read about Retrieve and Display Data. Here I’ve enhanced the same MXML by the following The LinkButton hidden until the datagrid change event is fired. Enabled the Data Tips for ‘Posts’ column to show tool tips text on roll over. Made it a scalable layout by using constraint-based layout. Here is the MXML code, I’ve highlighted the changes...
Read MoreSending Arrays with offset Index.
Last time we saw the problem with sending ActionScipt 3 Associative Array. Now we let us see where associative arrays can help. Lets Make an Array with offset index in PHP: $arr =array(5=>5); in ActionScript: var arr:Array= []; arr[5]=5; Sending these arrays either way they go with the missing indices filled with null, so the PHP array comes to flash as arr=[null, null,...
Read MoreUnderstanding AMF0 and AS3 Array.
You might have already read about Array oddity in AMFPHP/Flex 2. AS3 Associative Arrays, when sent through AMF0 they include ‘length’ propery. But numeric index based Arrays are fine. I’ve created the following AMFPHP Service to showcase this issue. It is a simple service with a remote method that converts any given object to string and returns...
Read MoreHow to load data from a remote URL?
I found that the DataLoadingTest class given in Adobe Labs ActionScript 3 Resources site was buggy and did not work. I’ve corrected the file myself and made it work. Here is the working code ActionScript3 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162package { import...
Read MorePorting XMLHighlighter class to ActionScript 3.
XMLHighlighter generates color highlighted pretty printed HTML code for the given XML document, I have ported it from ActionScript 2 to ActionScript 3. Here is what I learned during the process XML object in ActionScript 3 is different (It is ECMAScript for XML (E4X)). For backward compatibility we have XMLDocument class which is equalent to XML in Actionscript 3. In ActionScript 3 we need to...
Read MoreEasy way to Randomize an Array.
Here is the sample code to shuffle the contents of an array 123456789// Here is a simple function for randomizing the array function randomsort(a, b) { return Math.random()>.5 ? -1 : 1; } //usage example var arr = [1, 2, 3, 4, 5]; arr.sort(randomsort); trace(arr); //traces 4,3,1,5,2 ...
Read MoreGenerating Unique Random Number for Flash Lite 1 and 1.1.
Generating Unique random number for Flash Lite 1.1 is tricky because of the Flash 4 style syntax. I’ve made a sample application which shows how this can be achieved. Here is the SWF showcasing this You can download the FLA from...
Read Moreincluding Actionscript 1 files in Actionscript 2 Project.
When we are including an AS1 file in an Fla which has to be published as AS2, we need to be careful in naming the include file. There shouldn’t be any object initialized in _global which has the same name as the include file. Say for example, I had a include file called Security.As and inside that had _global.Security=new Object(). When I published I got the following ...
Read MoreXML Shortcuts V2 released
Here you can download the second version of XMLShortcuts component which helps to access XMLNodes easily. Refer to Online Help document below for more info <a href=”/HelpPanel/?target=XMLShortcuts” target=”_blank”>XMLShortcuts Online...
Read MoreXMLShortcuts Version 2 coming soon.
I’m already working on version 2 of this XMLNode easy access component. It will give better performance than the previous version. It will have two components, XMLShortcuts Lite and XMLShortcuts Pro. Both provide the same functionality. XMLShortcuts Lite is optimized for file size & memory, it is recommended for Small Projects. XMLShortcuts Pro is optimized for processor &...
Read MoreXML Shortcut – Accessing XMLNode easily as a Object
If you hate accessing XMLNodes using myXML.firstChild.childNodes[3] approach, there are already couple of other approaches to deal with. Before getting to know my new approach lets examine the other possibilities. What do you think? Will XML Shortcuts component be of any use to you? Express your views in the comments, based on the demand I will release the...
Read MoreNew Version of ActionScript() function for improved AS Tracing.
I’ve completely re-written my ActionScript function. For those who are hearing about it for the first time ActionScript(Object, ‘name_of_the_variable’) – gets complete reusable actionscript string of the Object including circular references. Now it takes care of special characters in properties and also shows null values properly Now the actionscript produced is more...
Read MoreAn Idea to document your components.
This could be an easy way to document your component. We need track the properties and methods of a component by looping through the instance. Say for example the following example can generate the color syntax xml for any component instance, we need to delete unwanted entries manually that’s all. 123456789101112<span style="color:...
Read MoreReal toString() method.
This code snippet helps to get the real insight of an object instead of returning ‘[object object]‘ while tracing. Now I’ve completely rewritten it to take care of circular references, escaping quotes in Strings, and function references. Also I’ve created a “ActionScript” function to get the complete picture of the object. We can use the produced ...
Read MoreEnter, Backspace and Delete Keys fail when using Listeners for Textbox
‘ve noticed it many times. When we use listeners for Textbox or while using onChanged event some times it fails to render backspace, delete and enter keys unless we have a selection. Removing the Listener reverts back to normal. Did anybody had the same problem and found a solution? If yes then please post it in the comments.
Read MoreMX: MovieClip-swapClip.
When we need to replace a movie clip on stage with another with a Linkage ID the following code will be useful. 1234567891011121314<span style="color: #993300;">MovieClip</span>.<span style="color: #000087;">prototype</span>.swapClip = <span style="color: #993300;">function</span>(idName) { ...
Read MoreFlash Remoting Using AMF in PHP!
There is an interesting thread in Flash-DB which is discussing the various possibilities of passing data to flash from PHP. The attractive part in that to me is using AMF(Action Message Format – binary format for sending Flash Objects) with PHP. Musicman has come out with this PHP class which can construct the AMF data. Alessandro(sephiroth) has put a sample application using this...
Read MoreXMLNode.transformTags() Source Code Released!
Wish you all very happy and prosperous New Year 2003! Here is my tiny gift for the new year, transformTags basically allows you to add, remove, and modify tags in any valid XML. You can take a look and download the source code from here! For more usage examples take a look at my previous posts. I will also try to put more examples.
Read MoreCreating Unique Random Response
Whether we are developing a game or e-learning application we need to create random response which is unique and not repeating. Say for example if you are developing a Quiz application where you have 10 questions, you want to pick the question randomly, but the same question should not be repeated. Here is a custom class which we can use to produce such random values. I will write more about it...
Read MoreScreenweaver MX Beta 3 is released
The current Flash player is primarily used to display Flash content that was initially created for the web. Screenweaver is an extension to the Flash player that aims at providing Flash developers with a toolset to produce rich media desktop applications. By doing so it enables the developer to apply their existing skill set to new uses of Flash technology. Screenweaver enables the Flash MX,...
Read MoreEnabling Flash Links in Director
It’s time for Director again (time for Director MX in fact!). Somebody sent me a mail asking why the getURL functions which are supposed to open the links are failing when we embed the flash movie in director? The reason is simple, both getURL and FSCommand are methods for flash to communicate to the container application. When we embed the flash file in a HTML page Flash plugin for the...
Read MoreString.changeCase(Title || Sentence || Toggle).
ActionScript Standard Library project is really picking up. For those who are hearing it for the first time, the ActionScript Standard Library is a collection of ActionScript classes and libraries that aims to create and provide a standard library of functionality to ActionScript. ASL is an Open Source initiative by Mike Chambers, the community manager of macromedia. Currently 33 developers...
Read MoreObject to ActionScript Utility
Many times we need this! We create objects and arrays and modify them through code to get them as we want. Finally the object is ready but every time it is created using the same complex procedure when the SWF runs. This affects the performance to some extent. Also sometimes we need to see what’s in that object at that movement for debugging (including remote debugging) So I’ve...
Read More

